forked from MirrorHub/synapse
Remove unnecessary extra function call layer
This commit is contained in:
parent
8a1817f0d2
commit
6982320572
2 changed files with 16 additions and 31 deletions
|
@ -28,7 +28,7 @@ from synapse.metrics import (
|
||||||
event_processing_loop_room_count,
|
event_processing_loop_room_count,
|
||||||
)
|
)
|
||||||
from synapse.metrics.background_process_metrics import run_as_background_process
|
from synapse.metrics.background_process_metrics import run_as_background_process
|
||||||
from synapse.util import make_log_failure_errback
|
from synapse.util import log_failure
|
||||||
from synapse.util.logcontext import make_deferred_yieldable, run_in_background
|
from synapse.util.logcontext import make_deferred_yieldable, run_in_background
|
||||||
from synapse.util.metrics import Measure
|
from synapse.util.metrics import Measure
|
||||||
|
|
||||||
|
@ -37,17 +37,6 @@ logger = logging.getLogger(__name__)
|
||||||
events_processed_counter = Counter("synapse_handlers_appservice_events_processed", "")
|
events_processed_counter = Counter("synapse_handlers_appservice_events_processed", "")
|
||||||
|
|
||||||
|
|
||||||
def log_failure(failure):
|
|
||||||
logger.error(
|
|
||||||
"Application Services Failure",
|
|
||||||
exc_info=(
|
|
||||||
failure.type,
|
|
||||||
failure.value,
|
|
||||||
failure.getTracebackObject()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationServicesHandler(object):
|
class ApplicationServicesHandler(object):
|
||||||
|
|
||||||
def __init__(self, hs):
|
def __init__(self, hs):
|
||||||
|
@ -114,10 +103,9 @@ class ApplicationServicesHandler(object):
|
||||||
if not self.started_scheduler:
|
if not self.started_scheduler:
|
||||||
def start_scheduler():
|
def start_scheduler():
|
||||||
return self.scheduler.start().addErrback(
|
return self.scheduler.start().addErrback(
|
||||||
make_log_failure_errback(
|
log_failure, "Application Services Failure",
|
||||||
"Application Services Failure",
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
run_as_background_process("as_scheduler", start_scheduler)
|
run_as_background_process("as_scheduler", start_scheduler)
|
||||||
self.started_scheduler = True
|
self.started_scheduler = True
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,9 @@ class Clock(object):
|
||||||
call = task.LoopingCall(f)
|
call = task.LoopingCall(f)
|
||||||
call.clock = self._reactor
|
call.clock = self._reactor
|
||||||
d = call.start(msec / 1000.0, now=False)
|
d = call.start(msec / 1000.0, now=False)
|
||||||
d.addErrback(make_log_failure_errback(
|
d.addErrback(
|
||||||
"Looping call died", consumeErrors=False,
|
log_failure, "Looping call died", consumeErrors=False,
|
||||||
))
|
)
|
||||||
return call
|
return call
|
||||||
|
|
||||||
def call_later(self, delay, callback, *args, **kwargs):
|
def call_later(self, delay, callback, *args, **kwargs):
|
||||||
|
@ -114,7 +114,7 @@ def batch_iter(iterable, size):
|
||||||
return iter(lambda: tuple(islice(sourceiter, size)), ())
|
return iter(lambda: tuple(islice(sourceiter, size)), ())
|
||||||
|
|
||||||
|
|
||||||
def make_log_failure_errback(msg, consumeErrors=True):
|
def log_failure(failure, msg, consumeErrors=True):
|
||||||
"""Creates a function suitable for passing to `Deferred.addErrback` that
|
"""Creates a function suitable for passing to `Deferred.addErrback` that
|
||||||
logs any failures that occur.
|
logs any failures that occur.
|
||||||
|
|
||||||
|
@ -127,7 +127,6 @@ def make_log_failure_errback(msg, consumeErrors=True):
|
||||||
func(Failure)
|
func(Failure)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def log_failure(failure):
|
|
||||||
logger.error(
|
logger.error(
|
||||||
msg,
|
msg,
|
||||||
exc_info=(
|
exc_info=(
|
||||||
|
@ -139,5 +138,3 @@ def make_log_failure_errback(msg, consumeErrors=True):
|
||||||
|
|
||||||
if not consumeErrors:
|
if not consumeErrors:
|
||||||
return failure
|
return failure
|
||||||
|
|
||||||
return log_failure
|
|
||||||
|
|
Loading…
Reference in a new issue