mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-10 15:47:59 -05:00
fix(backend): Fix scheduler ayncio loop issue & update late execution message report
This commit is contained in:
@@ -72,8 +72,13 @@ def get_notification_client():
|
||||
return get_service_client(NotificationManagerClient)
|
||||
|
||||
|
||||
@thread_cached
|
||||
def get_event_loop():
|
||||
return asyncio.new_event_loop()
|
||||
|
||||
|
||||
def execute_graph(**kwargs):
|
||||
asyncio.run(_execute_graph(**kwargs))
|
||||
get_event_loop().run_until_complete(_execute_graph(**kwargs))
|
||||
|
||||
|
||||
async def _execute_graph(**kwargs):
|
||||
@@ -110,11 +115,17 @@ def report_late_executions() -> str:
|
||||
|
||||
num_late_executions = len(late_executions)
|
||||
num_users = len(set([r.user_id for r in late_executions]))
|
||||
|
||||
late_execution_details = [
|
||||
f"* `Execution ID: {exec.id}, Graph ID: {exec.graph_id}v{exec.graph_version}, User ID: {exec.user_id}, Created At: {exec.started_at.isoformat()}`"
|
||||
for exec in late_executions
|
||||
]
|
||||
|
||||
error = LateExecutionException(
|
||||
f"Late executions detected: {num_late_executions} late executions from {num_users} users "
|
||||
f"in the last {config.execution_late_notification_checkrange_secs} seconds. "
|
||||
f"Graph has been queued for more than {config.execution_late_notification_threshold_secs} seconds. "
|
||||
"Please check the executor status."
|
||||
f"Please check the executor status. Details:\n{'\n'.join(late_execution_details)}"
|
||||
)
|
||||
msg = str(error)
|
||||
sentry_capture_error(error)
|
||||
|
||||
Reference in New Issue
Block a user