File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Expand file tree Collapse file tree 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):
191191 return_when = asyncio .FIRST_COMPLETED )
192192
193193 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+
194200 # Asyncio fails to properly remove the readers and writers
195201 # when the task doing recv() or send() is cancelled, so
196202 # 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):
609609 pass
610610 finally :
611611 self .waiter = None
612- self .transport.abort()
612+ self .transport.abort()
613613
614614 def _request_cancel (self ):
615615 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):
16041604 dsn = 'postgresql://foo/postgres?sslmode=prefer' ,
16051605 host = 'localhost' ,
16061606 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 ()
16121615
16131616 async def test_nossl_connection_pool (self ):
16141617 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):
842842 await pool .release (con )
843843
844844 self .assertIsNone (pool ._holders [0 ]._con )
845+ await pool .close ()
845846
846847 async def test_pool_set_connection_args (self ):
847848 pool = await self .create_pool (database = 'postgres' ,
@@ -883,6 +884,8 @@ async def test_pool_set_connection_args(self):
883884 con = await pool .acquire ()
884885 self .assertEqual (con .get_settings ().application_name ,
885886 'set_conn_args_test_2' )
887+ await pool .release (con )
888+ await pool .close ()
886889
887890 async def test_pool_init_race (self ):
888891 pool = self .create_pool (database = 'postgres' , min_size = 1 , max_size = 1 )
You can’t perform that action at this time.
0 commit comments