This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Closed
Description
Spotted when I was reading through sytest logs.
21082-2021-12-06 18:04:19,715 - synapse.metrics.background_process_metrics - 246 - ERROR - generic_presence.on_shutdown-0 - Background process 'generic_presence.on_shutdown' threw an exception
21083-Traceback (most recent call last):
21084- File "/venv/lib/python3.7/site-packages/synapse/metrics/background_process_metrics.py", line 242, in run
21085- return await func(*args, **kwargs)
21086-TypeError: object NoneType can't be used in 'await' expression
The problem is that we register a call to run_as_background_process
before shutdown here. We pass it the callable self._on_shutdown
. The latter is a synchronous function, but run_as_background_process
expects an async function.
synapse/synapse/handlers/presence.py
Lines 416 to 428 in 75ca0a6
The symptom was introduced in #10847 when we removed maybe_awaitable
. But the underlying cause is that _on_shutdown
didn't return a Deferred back when we expected it to. (Plus addSystemEventTrigger
obscures the call from mypy. Probably extra confusion when this was rewritten from twisted defers to asyncs.)