@@ -256,7 +256,6 @@ cdef class BaseThinPoolImpl(BasePoolImpl):
256256 Called when a new connection is created on acquire with the lock held.
257257 """
258258 if orig_conn_impl is not None :
259- self ._busy_conn_impls.remove(orig_conn_impl)
260259 self ._busy_conn_impls.append(new_conn_impl)
261260 else :
262261 new_conn_impl._is_pool_extra = True
@@ -621,7 +620,6 @@ cdef class ThinPoolImpl(BaseThinPoolImpl):
621620 temp_conn_impl = None
622621 break
623622 temp_conn_impl = < ThinConnImpl> result
624- self ._busy_conn_impls.append(temp_conn_impl)
625623 if must_reconnect:
626624 break
627625
@@ -630,9 +628,11 @@ cdef class ThinPoolImpl(BaseThinPoolImpl):
630628 if requires_ping:
631629 try :
632630 temp_conn_impl.ping()
633- except exceptions.DatabaseError :
631+ except exceptions.Error :
634632 temp_conn_impl._force_close()
635633 if temp_conn_impl._protocol._transport is not None :
634+ with self ._condition:
635+ self ._busy_conn_impls.append(temp_conn_impl)
636636 return temp_conn_impl
637637
638638 # a new connection needs to be created
@@ -710,7 +710,6 @@ cdef class AsyncThinPoolImpl(BaseThinPoolImpl):
710710 temp_conn_impl = None
711711 break
712712 temp_conn_impl = < AsyncThinConnImpl> result
713- self ._busy_conn_impls.append(temp_conn_impl)
714713 if must_reconnect:
715714 break
716715
@@ -719,9 +718,11 @@ cdef class AsyncThinPoolImpl(BaseThinPoolImpl):
719718 if requires_ping:
720719 try :
721720 await temp_conn_impl.ping()
722- except exceptions.DatabaseError :
721+ except exceptions.Error :
723722 temp_conn_impl._force_close()
724723 if temp_conn_impl._protocol._transport is not None :
724+ async with self ._condition:
725+ self ._busy_conn_impls.append(temp_conn_impl)
725726 return temp_conn_impl
726727
727728 # a new connection needs to be created
0 commit comments