File tree 4 files changed +18
-6
lines changed
4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,12 @@ async def handle(self):
191
191
return_when = asyncio .FIRST_COMPLETED )
192
192
193
193
finally :
194
+ if self .proxy_to_backend_task is not None :
195
+ self .proxy_to_backend_task .cancel ()
196
+
197
+ if self .proxy_from_backend_task is not None :
198
+ self .proxy_from_backend_task .cancel ()
199
+
194
200
# Asyncio fails to properly remove the readers and writers
195
201
# when the task doing recv() or send() is cancelled, so
196
202
# we must remove the readers and writers manually before
Original file line number Diff line number Diff line change @@ -609,7 +609,7 @@ cdef class BaseProtocol(CoreProtocol):
609
609
pass
610
610
finally :
611
611
self .waiter = None
612
- self .transport.abort()
612
+ self .transport.abort()
613
613
614
614
def _request_cancel (self ):
615
615
self .cancel_waiter = self .create_future()
Original file line number Diff line number Diff line change @@ -1604,11 +1604,14 @@ async def test_nossl_connection_prefer_cancel(self):
1604
1604
dsn = 'postgresql://foo/postgres?sslmode=prefer' ,
1605
1605
host = 'localhost' ,
1606
1606
user = 'ssl_user' )
1607
- self .assertFalse (con ._protocol .is_ssl )
1608
- with self .assertRaises (asyncio .TimeoutError ):
1609
- await con .execute ('SELECT pg_sleep(5)' , timeout = 0.5 )
1610
- val = await con .fetchval ('SELECT 123' )
1611
- self .assertEqual (val , 123 )
1607
+ try :
1608
+ self .assertFalse (con ._protocol .is_ssl )
1609
+ with self .assertRaises (asyncio .TimeoutError ):
1610
+ await con .execute ('SELECT pg_sleep(5)' , timeout = 0.5 )
1611
+ val = await con .fetchval ('SELECT 123' )
1612
+ self .assertEqual (val , 123 )
1613
+ finally :
1614
+ await con .close ()
1612
1615
1613
1616
async def test_nossl_connection_pool (self ):
1614
1617
pool = await self .create_pool (
Original file line number Diff line number Diff line change @@ -842,6 +842,7 @@ async def test_pool_expire_connections(self):
842
842
await pool .release (con )
843
843
844
844
self .assertIsNone (pool ._holders [0 ]._con )
845
+ await pool .close ()
845
846
846
847
async def test_pool_set_connection_args (self ):
847
848
pool = await self .create_pool (database = 'postgres' ,
@@ -883,6 +884,8 @@ async def test_pool_set_connection_args(self):
883
884
con = await pool .acquire ()
884
885
self .assertEqual (con .get_settings ().application_name ,
885
886
'set_conn_args_test_2' )
887
+ await pool .release (con )
888
+ await pool .close ()
886
889
887
890
async def test_pool_init_race (self ):
888
891
pool = self .create_pool (database = 'postgres' , min_size = 1 , max_size = 1 )
You can’t perform that action at this time.
0 commit comments