mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 15:49:40 -05:00
Factor PusherPool._start_pusher out of _start_pushers
... and use it from start_pusher_by_id. This mostly simplifies start_pusher_by_id.
This commit is contained in:
parent
3e8b02c939
commit
04277d0ed8
@ -192,6 +192,9 @@ class PusherPool:
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def start_pusher_by_id(self, app_id, pushkey, user_id):
|
def start_pusher_by_id(self, app_id, pushkey, user_id):
|
||||||
"""Look up the details for the given pusher, and start it"""
|
"""Look up the details for the given pusher, and start it"""
|
||||||
|
if not self._start_pushers:
|
||||||
|
return
|
||||||
|
|
||||||
resultlist = yield self.store.get_pushers_by_app_id_and_pushkey(
|
resultlist = yield self.store.get_pushers_by_app_id_and_pushkey(
|
||||||
app_id, pushkey
|
app_id, pushkey
|
||||||
)
|
)
|
||||||
@ -202,8 +205,7 @@ class PusherPool:
|
|||||||
p = r
|
p = r
|
||||||
|
|
||||||
if p:
|
if p:
|
||||||
|
self._start_pusher(p)
|
||||||
self._start_pushers([p])
|
|
||||||
|
|
||||||
def _start_pushers(self, pushers):
|
def _start_pushers(self, pushers):
|
||||||
if not self.start_pushers:
|
if not self.start_pushers:
|
||||||
@ -211,12 +213,27 @@ class PusherPool:
|
|||||||
return
|
return
|
||||||
logger.info("Starting %d pushers", len(pushers))
|
logger.info("Starting %d pushers", len(pushers))
|
||||||
for pusherdict in pushers:
|
for pusherdict in pushers:
|
||||||
|
self._start_pusher(pusherdict)
|
||||||
|
logger.info("Started pushers")
|
||||||
|
|
||||||
|
def _start_pusher(self, pusherdict):
|
||||||
|
"""Start the given pusher
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pusherdict (dict):
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
p = self.pusher_factory.create_pusher(pusherdict)
|
p = self.pusher_factory.create_pusher(pusherdict)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Couldn't start a pusher: caught Exception")
|
logger.exception("Couldn't start a pusher: caught Exception")
|
||||||
continue
|
return
|
||||||
if p:
|
|
||||||
|
if not p:
|
||||||
|
return
|
||||||
|
|
||||||
appid_pushkey = "%s:%s" % (
|
appid_pushkey = "%s:%s" % (
|
||||||
pusherdict['app_id'],
|
pusherdict['app_id'],
|
||||||
pusherdict['pushkey'],
|
pusherdict['pushkey'],
|
||||||
@ -228,8 +245,6 @@ class PusherPool:
|
|||||||
byuser[appid_pushkey] = p
|
byuser[appid_pushkey] = p
|
||||||
run_in_background(p.on_started)
|
run_in_background(p.on_started)
|
||||||
|
|
||||||
logger.info("Started pushers")
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def remove_pusher(self, app_id, pushkey, user_id):
|
def remove_pusher(self, app_id, pushkey, user_id):
|
||||||
appid_pushkey = "%s:%s" % (app_id, pushkey)
|
appid_pushkey = "%s:%s" % (app_id, pushkey)
|
||||||
|
Loading…
Reference in New Issue
Block a user