@@ -614,20 +614,19 @@ def _release_leaked_connection(fut):
614614 self ._check_init ()
615615
616616 acquire_fut = asyncio .ensure_future (_acquire_impl ())
617- if timeout is None :
618- return await acquire_fut
619- else :
620- try :
621- return await asyncio .wait_for (
622- acquire_fut , timeout = timeout )
623- except asyncio .CancelledError :
624- # Ensure connection is marked as not in use.
625- # The cancellation may have raced the acquire, leading
626- # to the acquire completing but the wait_for to be
627- # cancelled.
628- # See: https://bugs.python.org/issue37658
629- acquire_fut .add_done_callback (_release_leaked_connection )
630- raise
617+ try :
618+ # Calling wait_for with timeout=None will shortcut to run without
619+ # timeout
620+ return await asyncio .wait_for (
621+ acquire_fut , timeout = timeout )
622+ except asyncio .CancelledError :
623+ # Ensure connection is marked as not in use.
624+ # The cancellation may have raced the acquire, leading
625+ # to the acquire completing but the wait_for to be
626+ # cancelled.
627+ # See: https://bugs.python.org/issue37658
628+ acquire_fut .add_done_callback (_release_leaked_connection )
629+ raise
631630
632631 async def release (self , connection , * , timeout = None ):
633632 """Release a database connection back to the pool.
0 commit comments