element-hq / element-hq/synapse

`run_in_background` calls whose return value is discarded can re-start finished logging contexts

Open
#13,090 0 comments 0 reactions 0 assignees View on GitHub
S-Tolerable T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#13090](https://github.com/matrix-org/synapse/issues/13090).

---

A more general version of #12987.

When we launch a task using `run_in_background`, the task inherits the current logging context. If we neglect to await the task, we may finish our current logging context while the background task is still using it. We ought to either await such background tasks or give them their own logging contexts.

clokep notes that we can find such calls using `grep -r " run_in_background" synapse` and there are a few places we do so.

Note that it does not make sense to write `await make_deferred_yieldable(run_in_background(f, ...))`, as it could be written as `await f(...)`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.