@@ -108,6 +108,8 @@ def _get_stream_transports(self, local_token: int) -> typing.Set[asyncio.Transpo
108
108
return self ._stream_trasports [local_token ] if local_token in self ._stream_trasports else set ()
109
109
110
110
async def _timeout_handler (self , message_id : int , chat_id : int , local_token : int , size : int ):
111
+ _debounce : typing .Optional [AsyncDebounce ] = None # avoid garbage collector
112
+
111
113
if all (t .is_closing () for t in self ._get_stream_transports (local_token )):
112
114
blocks = (size // self ._config .block_size ) + 1
113
115
@@ -120,10 +122,8 @@ async def _timeout_handler(self, message_id: int, chat_id: int, local_token: int
120
122
remain_blocks = blocks - len (self ._downloaded_blocks [local_token ])
121
123
del self ._downloaded_blocks [local_token ]
122
124
123
- _debounce = None
124
-
125
125
if local_token in self ._stream_debounce :
126
- _debounce = self ._stream_debounce [local_token ] # avoid garbage collector
126
+ _debounce = self ._stream_debounce [local_token ]
127
127
del self ._stream_debounce [local_token ]
128
128
129
129
if local_token in self ._stream_trasports :
@@ -140,6 +140,8 @@ async def _timeout_handler(self, message_id: int, chat_id: int, local_token: int
140
140
if local_token in self ._stream_debounce :
141
141
self ._stream_debounce [local_token ].reschedule ()
142
142
143
+ del _debounce
144
+
143
145
async def _stream_handler (self , request : Request ) -> typing .Optional [Response ]:
144
146
_message_id : str = request .match_info ["message_id" ]
145
147
0 commit comments