mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
fix(executor): wrap _handle_low_balance in to_thread to avoid blocking
The post-execution low-balance check in on_node_execution called _handle_low_balance directly. _handle_low_balance does sync DB work, and on_node_execution is async, so the call blocked the event loop. Sentry caught it. Wrap in asyncio.to_thread. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -709,7 +709,11 @@ class ExecutionProcessor:
|
||||
)
|
||||
if extra_cost > 0:
|
||||
execution_stats.extra_cost += extra_cost
|
||||
self._handle_low_balance(
|
||||
# Wrap in to_thread — _handle_low_balance does sync DB
|
||||
# work and we're in an async method, so calling it
|
||||
# directly would block the event loop.
|
||||
await asyncio.to_thread(
|
||||
self._handle_low_balance,
|
||||
db_client=get_db_client(),
|
||||
user_id=node_exec.user_id,
|
||||
current_balance=remaining_balance,
|
||||
|
||||
Reference in New Issue
Block a user