Don't spuriously create new listeners

This commit is contained in:
Erik Johnston 2015-06-18 11:12:03 +01:00
parent 9bc36b7f31
commit 10a67f0d69
1 changed files with 6 additions and 5 deletions

View File

@ -350,14 +350,15 @@ class Notifier(object):
while not result and not timed_out[0]: while not result and not timed_out[0]:
new_token = yield deferred new_token = yield deferred
result = yield callback(current_token, new_token)
current_token = new_token
if not result:
deferred = defer.Deferred() deferred = defer.Deferred()
listener = _NotificationListener(deferred, timeout) listener = _NotificationListener(deferred, timeout)
listeners.append(listener) listeners.append(listener)
user_stream.listeners.add(listener) user_stream.listeners.add(listener)
result = yield callback(current_token, new_token)
current_token = new_token
if timer[0] is not None: if timer[0] is not None:
try: try:
self.clock.cancel_call_later(timer[0]) self.clock.cancel_call_later(timer[0])