Make on_started synchronous too

This brings it into line with on_new_notifications and on_new_receipts. It
requires a little bit of hoop-jumping in EmailPusher to load the throttle
params before the first loop.
This commit is contained in:
Richard van der Hoff 2018-10-22 16:12:11 +01:00
parent e7a16c6210
commit f749607c91
3 changed files with 21 additions and 11 deletions

View file

@ -72,16 +72,9 @@ class EmailPusher(object):
self.processing = False
@defer.inlineCallbacks
def on_started(self):
if self.mailer is not None:
try:
self.throttle_params = yield self.store.get_throttle_params_by_room(
self.pusher_id
)
self._start_processing()
except Exception:
logger.exception("Error starting email pusher")
self._start_processing()
def on_stop(self):
if self.timed_call:
@ -116,6 +109,12 @@ class EmailPusher(object):
try:
self.processing = True
if self.throttle_params is None:
# this is our first loop: load up the throttle params
self.throttle_params = yield self.store.get_throttle_params_by_room(
self.pusher_id
)
# if the max ordering changes while we're running _unsafe_process,
# call it again, and so on until we've caught up.
while True: