Skip to content

Commit

Permalink
Fix RuntimeError: dictionary changed size during iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Apr 7, 2019
1 parent 37574b6 commit 82ad165
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yeelib/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ async def _restart():

async def remove_missing_bulbs(timeout=60):
while True:
missing_bulbs = (
missing_bulbs = [
idx
for idx, bulb in bulbs.items()
if bulb.last_seen < time.time() - timeout
)
]
for idx in missing_bulbs:
logger.info('%r has not been seen in a while and will be removed', bulbs[idx])
del bulbs[idx]
Expand Down

0 comments on commit 82ad165

Please sign in to comment.