@@ -614,20 +614,18 @@ def _release_leaked_connection(fut):
614
614
self ._check_init ()
615
615
616
616
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 timeout
619
+ return await asyncio .wait_for (
620
+ acquire_fut , timeout = timeout )
621
+ except asyncio .CancelledError :
622
+ # Ensure connection is marked as not in use.
623
+ # The cancellation may have raced the acquire, leading
624
+ # to the acquire completing but the wait_for to be
625
+ # cancelled.
626
+ # See: https://bugs.python.org/issue37658
627
+ acquire_fut .add_done_callback (_release_leaked_connection )
628
+ raise
631
629
632
630
async def release (self , connection , * , timeout = None ):
633
631
"""Release a database connection back to the pool.
0 commit comments