Heartbeat on acquired locks copy

Instead of heartbeating on a collection that may
be changing size while iterating ensure that we only
iterate over a copy (that won't change size) during
iteration.

The python set() docs say that it is inherently
unpredictable to iterate on a set while its being mutated
so we should try to avoid that kind of case if we can.

Change-Id: I6f103a5528b3f62f1c8d9e501e8cadff4221ee40
This commit is contained in:
Joshua Harlow 2015-04-21 17:21:31 -07:00
parent e4bbade4ef
commit 16490e5d82
1 changed files with 1 additions and 1 deletions

View File

@ -434,7 +434,7 @@ class RedisDriver(coordination.CoordinationDriver):
expiry_ms = max(0, int(self.membership_timeout * 1000.0))
self._client.psetex(beat_id, time_ms=expiry_ms,
value=b"Not dead!")
for lock in self._acquired_locks:
for lock in self._acquired_locks.copy():
try:
lock.heartbeat()
except coordination.ToozError: