Skip to content

Commit fa41ec6

Browse files
committed
Merge pull request dpkp#312 from dpkp/reentrant_timer_py26
Fix python2.6 threading.Event bug in ReentrantTimer
2 parents f0f3744 + a21f701 commit fa41ec6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kafka/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ def __init__(self, t, fn, *args, **kwargs):
126126
self.active = None
127127

128128
def _timer(self, active):
129-
while not active.wait(self.t):
129+
# python2.6 Event.wait() always returns None
130+
# python2.7 and greater returns the flag value (true/false)
131+
# we want the flag value, so add an 'or' here for python2.6
132+
# this is redundant for later python versions (FLAG OR FLAG == FLAG)
133+
while not (active.wait(self.t) or active.is_set()):
130134
self.fn(*self.args, **self.kwargs)
131135

132136
def start(self):

0 commit comments

Comments
 (0)