Discussion:
svnpubsub/client.py: RuntimeError: dictionary changed size during iteration
sebb
2018-08-23 12:54:16 UTC
Permalink
When running a version of watcher.py I got the following error:

File ".../svnpubsub/client.py", line 251, in run_forever
self._check_stale()
File ".../svnpubsub/client.py", line 216, in _check_stale
for client in asyncore.socket_map.values():
RuntimeError: dictionary changed size during iteration

Is this a known issue?

S.
Branko Čibej
2018-10-27 16:59:06 UTC
Permalink
Post by sebb
File ".../svnpubsub/client.py", line 251, in run_forever
self._check_stale()
File ".../svnpubsub/client.py", line 216, in _check_stale
RuntimeError: dictionary changed size during iteration
Is this a known issue?
It is now, since you created #4770 ... :)

Can you try this patch:

Index: client.py
===================================================================
--- client.py (revision 1844264)
+++ client.py (working copy)
@@ -213,17 +213,19 @@ class MultiClient(object):

def _check_stale(self):
now = time.time()
+ stale = []
for client in asyncore.socket_map.values():
if client.last_activity + STALE_DELAY < now:
- # Whoops. No activity in a while. Signal this fact, Close the
- # Client, then have it reconnected later on.
+ # Whoops. No activity in a while. Signal this fact.
self.event_callback(client.url, 'stale', client.last_activity)
+ stale.append(client)

- # This should remove it from .socket_map.
- client.close()
+ # Close stale clients, then have them reconnected later on.
+ for client in stale:
+ # This should remove it from .socket_map.
+ client.close()
+ self._reconnect_later(client.url)

- self._reconnect_later(client.url)
-
def _maybe_work(self):
# If we haven't reach the targetted time, or have no work to do,
# then fast-path exit






-- Brane

Loading...