Don't spuriously create new listeners

erikj/notifier_debug
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
deferred = defer.Deferred()
listener = _NotificationListener(deferred, timeout)
listeners.append(listener)
user_stream.listeners.add(listener)
result = yield callback(current_token, new_token) result = yield callback(current_token, new_token)
current_token = new_token current_token = new_token
if not result:
deferred = defer.Deferred()
listener = _NotificationListener(deferred, timeout)
listeners.append(listener)
user_stream.listeners.add(listener)
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])