[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [doctor/master] Can't modify during iteration



commit db8fc25e902c913f3ed683960681cef8dd7444a5
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Oct 4 13:41:40 2015 -0700

    Can't modify during iteration
    
    Oops, we'd hit 'RuntimeError: dictionary changed size during iteration' during
    the bit where we clear out old entries.
---
 fingerprint_change_checker.py |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fingerprint_change_checker.py b/fingerprint_change_checker.py
index 289f3c0..72cca9b 100755
--- a/fingerprint_change_checker.py
+++ b/fingerprint_change_checker.py
@@ -43,10 +43,11 @@ def main():
 
       # drop fingerprint changes that are over thirty days old
 
-      for fp in prior_fingerprints:
-        if time.time() - prior_fingerprints[fp] > THIRTY_DAYS:
-          log.debug("Removing fingerprint for %s:%s (%s) which was published %i days ago" % (relay.address, relay.or_port, fp, prior_fingerprints[fp] / 60 / 60 / 24))
-          del prior_fingerprints[fp]
+      old_fingerprints = [fp for fp in prior_fingerprints if (time.time() - prior_fingerprints[fp] > THIRTY_DAYS)]
+
+      for fp in old_fingerprints:
+        log.debug("Removing fingerprint for %s:%s (%s) which was published %i days ago" % (relay.address, relay.or_port, fp, prior_fingerprints[fp] / 60 / 60 / 24))
+        del prior_fingerprints[fp]
 
       # if we've changed more than three times in the last thirty days then alarm
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits