File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 11## unreleased
22
33# [ SELECT 1 only if we haven't seen any events] ( https://github.com/anna-money/asyncpg-listen/pull/222 )
4+ # [ No need to wait for a connection closure] ( https://github.com/anna-money/asyncpg-listen/pull/223 )
45
56
67## v0.0.8 (2025-05-25)
Original file line number Diff line number Diff line change @@ -46,11 +46,13 @@ class NotificationListener:
4646 __slots__ = (
4747 "__connect" ,
4848 "__reconnect_delay" ,
49+ "__tasks" ,
4950 )
5051
5152 def __init__ (self , connect : ConnectFunc , reconnect_delay : float = 5 ) -> None :
5253 self .__reconnect_delay = reconnect_delay
5354 self .__connect = connect
55+ self .__tasks = set ()
5456
5557 async def run (
5658 self ,
@@ -155,7 +157,9 @@ async def __read_notifications(
155157 await asyncio .sleep (per_attempt_keep_alive_budget - elapsed )
156158 logger .warning ("Connection was lost" )
157159 finally :
158- await asyncio .shield (connection .close ())
160+ close_task = asyncio .create_task (connection .close ())
161+ close_task .add_done_callback (self .__tasks .discard )
162+ self .__tasks .add (close_task )
159163 except Exception :
160164 if failed_connect_attempts < MAX_SILENCED_FAILED_CONNECT_ATTEMPTS :
161165 logger .warning ("Connection was lost or not established" , exc_info = True )
You can’t perform that action at this time.
0 commit comments