Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Update comments and docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Sep 25, 2019
1 parent 4fb3c12 commit a963181
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions synapse/metrics/background_process_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def run_as_background_process(desc, func, *args, **kwargs):
Args:
desc (str): a description for this background process type
func: a function, which may return a Deferred
func: a function, which may return a Deferred or a coroutine
args: positional args for func
kwargs: keyword args for func
Expand All @@ -199,11 +199,13 @@ def run():
_background_processes.setdefault(desc, set()).add(proc)

try:
# We ensureDeferred here to handle coroutines
result = func(*args, **kwargs)

# We need this check because ensureDeferred doesn't like when
# func doesn't return a Deferred or coroutine.
# We probably don't have an ensureDeferred in our call stack to handle
# coroutine results, so we need to ensureDeferred here.
#
# But we need this check because ensureDeferred doesn't like being
# called on immediate values (as opposed to Deferreds or coroutines).
if iscoroutine(result):
result = defer.ensureDeferred(result)

Expand Down

0 comments on commit a963181

Please sign in to comment.