From bddacb6dd180319303188ec031fe03916391edf3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 17 Jun 2015 15:15:51 +0100 Subject: [PATCH] Add some things to help debug notifer leak --- synapse/notifier.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/synapse/notifier.py b/synapse/notifier.py index 078abfc56d..46b1840a6d 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -21,6 +21,7 @@ from synapse.types import StreamToken import synapse.metrics import logging +import time logger = logging.getLogger(__name__) @@ -46,8 +47,9 @@ class _NotificationListener(object): notify the handler it is sufficient to resolve the deferred. """ - def __init__(self, deferred): + def __init__(self, deferred, timeout): self.deferred = deferred + self.created = int(time.time() * 1000) def notified(self): return self.deferred.called @@ -308,7 +310,7 @@ class Notifier(object): else: current_token = user_stream.current_token - listener = [_NotificationListener(deferred)] + listener = [_NotificationListener(deferred, timeout)] if timeout and not current_token.is_after(from_token): user_stream.listeners.add(listener[0]) @@ -341,7 +343,7 @@ class Notifier(object): while not result and not timed_out[0]: new_token = yield deferred deferred = defer.Deferred() - listener[0] = _NotificationListener(deferred) + listener[0] = _NotificationListener(deferred, timeout) user_stream.listeners.add(listener[0]) result = yield callback(current_token, new_token) current_token = new_token