Skip to content

Commit

Permalink
Avoid RuntimeError: dictionary changed size during iteration in `Se…
Browse files Browse the repository at this point in the history
…rver._shift_counters()` (#8828)
  • Loading branch information
hendrikmakait authored Aug 13, 2024
1 parent fd92ab8 commit 3db8c46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions distributed/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,12 @@ def func(data):
return {"status": "OK", "nbytes": len(data)}

def _shift_counters(self):
for counter in self.counters.values():
# Copy counters before iterating to avoid concurrent modification
for counter in list(self.counters.values()):
counter.shift()
if self.digests is not None:
for digest in self.digests.values():
# Copy digests before iterating to avoid concurrent modification
for digest in list(self.digests.values()):
digest.shift()

@property
Expand Down

0 comments on commit 3db8c46

Please sign in to comment.