From 279f05a14aeb0cb120881eb1ade6f84da0ecfd3b Mon Sep 17 00:00:00 2001 From: Dale Arbogast Date: Thu, 19 Feb 2026 16:49:50 -0500 Subject: [PATCH] fix: handle RuntimeError in notification_manager emit() asyncio.get_running_loop() raises RuntimeError when emit() is called from a thread without an active event loop (e.g. when the disk space check in project_manager triggers a log.warning notification from a threadpool worker). This causes a 500 Internal Server Error on project creation/open when disk usage is high, instead of the intended warning notification. Wrap the emit loop in try/except RuntimeError so that notifications are silently dropped when no event loop is available, rather than crashing the request. Fixes #2502 Fixes #2505 --- gns3server/compute/notification_manager.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gns3server/compute/notification_manager.py b/gns3server/compute/notification_manager.py index 30f0a8050..f4eecf76c 100644 --- a/gns3server/compute/notification_manager.py +++ b/gns3server/compute/notification_manager.py @@ -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():