Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend): fix lack of event loop on notification manager

Zamil Majdy7922e4add48e
diff --git a/autogpt_platform/backend/backend/notifications/notifications.py b/autogpt_platform/backend/backend/notifications/notifications.py
index 052fc453fd..9e2bb6f23b 100644
--- a/autogpt_platform/backend/backend/notifications/notifications.py
+++ b/autogpt_platform/backend/backend/notifications/notifications.py
@@ -198,7 +198,7 @@ class NotificationManager(AppService):
return settings.config.notification_service_port
@expose
- def queue_weekly_summary(self):
+ async def queue_weekly_summary(self):
# Use the existing event loop instead of creating a new one with asyncio.run()
asyncio.create_task(self._queue_weekly_summary())
@@ -232,7 +232,9 @@ class NotificationManager(AppService):
logger.exception(f"Error processing weekly summary: {e}")
@expose
- def process_existing_batches(self, notification_types: list[NotificationType]):
+ async def process_existing_batches(
+ self, notification_types: list[NotificationType]
+ ):
# Use the existing event loop instead of creating a new process
asyncio.create_task(self._process_existing_batches(notification_types))
@@ -887,6 +889,8 @@ class NotificationManagerClient(AppServiceClient):
def get_service_type(cls):
return NotificationManager
- process_existing_batches = NotificationManager.process_existing_batches
- queue_weekly_summary = NotificationManager.queue_weekly_summary
+ process_existing_batches = endpoint_to_sync(
+ NotificationManager.process_existing_batches
+ )
+ queue_weekly_summary = endpoint_to_sync(NotificationManager.queue_weekly_summary)
discord_system_alert = endpoint_to_sync(NotificationManager.discord_system_alert)