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(rnd): Guarantee execution ordering per node by waiting the node completion (#7855)

Zamil Majdy3d62cec55335
diff --git a/rnd/autogpt_server/autogpt_server/executor/manager.py b/rnd/autogpt_server/autogpt_server/executor/manager.py
index d93d4ab518..3ce28eafca 100644
--- a/rnd/autogpt_server/autogpt_server/executor/manager.py
+++ b/rnd/autogpt_server/autogpt_server/executor/manager.py
@@ -229,9 +229,9 @@ def _enqueue_next_nodes(
idata, msg = validate_exec(next_node, idata)
suffix = f"{next_output_name}>{next_input_name}~{ineid}:{msg}"
if not idata:
- logger.warning(f"{prefix} Re-enqueueing skipped: {suffix}")
+ logger.warning(f"{prefix} Enqueueing static-link skipped: {suffix}")
continue
- logger.warning(f"{prefix} Re-enqueued {suffix}")
+ logger.warning(f"{prefix} Enqueueing static-link execution {suffix}")
enqueued_executions.append(
add_enqueued_execution(iexec.node_exec_id, next_node_id, idata)
)
@@ -373,10 +373,11 @@ class Executor:
# Avoid parallel execution of the same node.
fut = futures.get(execution.node_id)
if fut and not fut.done():
- cls.wait_future(fut)
- logger.warning(f"{prefix} Re-enqueueing {execution.node_id}")
- queue.add(execution)
- continue
+ # TODO (performance improvement):
+ # Wait for the completion of the same node execution is blocking.
+ # To improve this we need a separate queue for each node.
+ # Re-enqueueing the data back to the queue will disrupt the order.
+ cls.wait_future(fut, timeout=None)
futures[execution.node_id] = cls.executor.submit(
cls.on_node_execution, queue, execution
@@ -395,9 +396,10 @@ class Executor:
logger.exception(f"{prefix} Failed graph execution: {e}")
@classmethod
- def wait_future(cls, future: Future):
+ def wait_future(cls, future: Future, timeout: int | None = 3):
try:
- future.result(timeout=3)
+ if not future.done():
+ future.result(timeout=timeout)
except TimeoutError:
# Avoid being blocked by long-running node, by not waiting its completion.
pass