@@ -269,11 +269,12 @@ async def _run(self) -> None:
269269 _logger .debug (
270270 "Received dispatch event: %s" , selected .message
271271 )
272- dispatch = Dispatch (selected .message .dispatch )
273- _existing_dispatch = self ._dispatches .get (dispatch .id )
272+ new_dispatch = Dispatch (selected .message .dispatch )
273+ _existing_dispatch = self ._dispatches .get (new_dispatch .id )
274274 is_new_or_newer = (
275275 _existing_dispatch is None
276- or dispatch .update_time > _existing_dispatch .update_time
276+ or new_dispatch .update_time
277+ > _existing_dispatch .update_time
277278 )
278279
279280 match selected .message .event :
@@ -282,43 +283,43 @@ async def _run(self) -> None:
282283 # was updated. The CREATE event is late in
283284 # this case
284285 if is_new_or_newer :
285- self ._dispatches [dispatch .id ] = dispatch
286+ self ._dispatches [new_dispatch .id ] = new_dispatch
286287 await self ._update_dispatch_schedule_and_notify (
287- dispatch , None , next_event_timer
288+ new_dispatch , None , next_event_timer
288289 )
289290 await self ._lifecycle_events_tx .send (
290- Created (dispatch = dispatch )
291+ Created (dispatch = new_dispatch )
291292 )
292293 case Event .UPDATED :
293294 # We might receive update before we fetched
294295 # the entry, so don't rely on it existing
295296 if is_new_or_newer :
296297 await self ._update_dispatch_schedule_and_notify (
297- dispatch ,
298- self ._dispatches .get (dispatch .id ),
298+ new_dispatch ,
299+ self ._dispatches .get (new_dispatch .id ),
299300 next_event_timer ,
300301 )
301- self ._dispatches [dispatch .id ] = dispatch
302+ self ._dispatches [new_dispatch .id ] = new_dispatch
302303 await self ._lifecycle_events_tx .send (
303- Updated (dispatch = dispatch )
304+ Updated (dispatch = new_dispatch )
304305 )
305306 case Event .DELETED :
306307 # The dispatch might already be deleted,
307308 # depending on the exact timing of fetch()
308309 # so we don't rely on it existing.
309310 if is_new_or_newer :
310- self ._dispatches .pop (dispatch .id , None )
311+ self ._dispatches .pop (new_dispatch .id , None )
311312
312- self ._deleted_dispatches [dispatch .id ] = (
313+ self ._deleted_dispatches [new_dispatch .id ] = (
313314 datetime .now (timezone .utc )
314315 )
315316
316317 await self ._update_dispatch_schedule_and_notify (
317- None , dispatch , next_event_timer
318+ None , new_dispatch , next_event_timer
318319 )
319320
320321 await self ._lifecycle_events_tx .send (
321- Deleted (dispatch = dispatch )
322+ Deleted (dispatch = new_dispatch )
322323 )
323324
324325 case StreamRetrying ():
0 commit comments