Merge pull request #2613 from dalearbo/fix/emit-threadpool-runtime-error

fix: handle RuntimeError in notification_manager emit()
This commit is contained in:
Jeremy Grossmann 2026-02-20 15:59:01 +08:00 committed by GitHub
commit 126a4099e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,8 +53,13 @@ class NotificationManager:
:param kwargs: Add this meta to the notification (project_id for example)
"""
for listener in self._listeners:
asyncio.get_running_loop().call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
try:
for listener in self._listeners:
asyncio.get_running_loop().call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
except RuntimeError:
# asyncio.get_running_loop() raises RuntimeError when called from
# a threadpool with no active event loop (e.g. disk space warnings)
pass
@staticmethod
def reset():