Skip to content

Commit

Permalink
Merge pull request #159 from AryazE/main
Browse files Browse the repository at this point in the history
Fixed problem with removing events during clean up
  • Loading branch information
axmsoftware authored Aug 6, 2024
2 parents fd483bc + bb9b876 commit 815a85d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openleadr/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,12 @@ async def _event_cleanup(self):
"""
Periodic task that will clean up completed and cancelled events in our memory.
"""
for event in self.received_events:
for i in range(len(self.received_events)-1, -1, -1):
event = self.received_events[i]
if event['event_descriptor']['event_status'] == 'cancelled' or \
utils.determine_event_status(event['active_period']) == 'completed':
logger.info(f"Removing event {event} because it is no longer relevant.")
self.received_events.pop(self.received_events.index(event))
self.received_events.pop(i)

async def _poll(self):
logger.debug("Now polling for new messages")
Expand Down

0 comments on commit 815a85d

Please sign in to comment.