Skip to content

Commit

Permalink
Fix Python 3.4 error in circus-top. Fix #891
Browse files Browse the repository at this point in the history
We were deleting elements of a dictionary when iterating over it
via `filter`. As `filter` returns an iterator in Python 3.4, this
was causing a "dictionary changed size during iteration" error.
  • Loading branch information
k4nar committed May 4, 2015
1 parent 5260dfa commit d5d3112
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions circus/stats/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ def main():
subtopic = 'all'

# Clean pids that have not been updated recently
def valid_pid(p): return p.isdigit() and p in watchers[watcher]

for pid in filter(valid_pid, watchers[watcher]):
for pid in tuple(p for p in watchers[watcher] if p.isdigit()):
if (last_refresh_for_pid[pid] <
time.time() - int(args.process_timeout)):
del watchers[watcher][pid]
Expand Down

0 comments on commit d5d3112

Please sign in to comment.