Skip to content

Commit

Permalink
fix max number of running process
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Nov 30, 2024
1 parent ec17796 commit 5764736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aiida_workgraph/engine/awaitable_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def resolve_awaitable(self, awaitable: Awaitable, value: Any) -> None:
raise AssertionError(f"Unsupported awaitable action: {awaitable.action}")

awaitable.resolved = True
# remove awaitabble from the list
self._awaitables = [a for a in self._awaitables if a.pk != awaitable.pk]
# remove awaitabble from the list, and use the same list reference
self._awaitables[:] = [a for a in self._awaitables if a.pk != awaitable.pk]

if not self.process.has_terminated():
# the process may be terminated, for example, if the process was killed or excepted
Expand Down
4 changes: 3 additions & 1 deletion tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_reset_node(wg_engine: WorkGraph) -> None:
assert len(wg.process.base.extras.get("_workgraph_queue")) == 1


@pytest.mark.usefixtures("started_daemon_client")
def test_max_number_jobs(add_code) -> None:
from aiida_workgraph import WorkGraph
from aiida.orm import Int
Expand All @@ -46,6 +47,7 @@ def test_max_number_jobs(add_code) -> None:
)
# Set the maximum number of running jobs inside the WorkGraph
wg.max_number_jobs = 2
wg.submit(wait=True, timeout=100)
wg.submit(wait=True, timeout=40)
report = get_workchain_report(wg.process, "REPORT")
assert "tasks ready to run: add2" in report
wg.tasks["add2"].outputs["sum"].value == 2

0 comments on commit 5764736

Please sign in to comment.