A local call waiting for a slot is reached by a stop, a delete or a cancel and ends without running; what a call emits after its flow was stopped is dropped as its result is; a node run by hand whose flow is stopped or deleted tells its caller but publishes no node_error; cancelling a node also ends its calls on workers
Docs / docs (push) Successful in 33s
Playwright Tests / test-playwright (1, 2) (push) Successful in 3m45s
Playwright Tests / test-playwright (2, 2) (push) Successful in 2m47s
pre-commit / pre-commit (push) Successful in 3m44s
Test Backend / test-backend (3.12) (push) Failing after 5m55s
Test Backend / test-backend (3.14) (push) Failing after 5m31s
Compose Smoke Test / test-compose (push) Successful in 33s
Playwright Tests / merge-reports (push) Successful in 1m19s
Docs / docs (push) Successful in 33s
Playwright Tests / test-playwright (1, 2) (push) Successful in 3m45s
Playwright Tests / test-playwright (2, 2) (push) Successful in 2m47s
pre-commit / pre-commit (push) Successful in 3m44s
Test Backend / test-backend (3.12) (push) Failing after 5m55s
Test Backend / test-backend (3.14) (push) Failing after 5m31s
Compose Smoke Test / test-compose (push) Successful in 33s
Playwright Tests / merge-reports (push) Successful in 1m19s
This commit is contained in:
@@ -176,6 +176,40 @@ def test_a_running_node_can_be_cancelled(pool):
|
||||
stopper.join()
|
||||
|
||||
|
||||
def test_a_call_waiting_for_a_slot_is_cancelled_before_it_runs(pool):
|
||||
"""A cancel missed a call queued for a slot, so it took the slot that
|
||||
cancelling the node ahead of it freed, and ran."""
|
||||
outcome: dict[str, object] = {}
|
||||
|
||||
def call(node: str, code: str) -> None:
|
||||
try:
|
||||
outcome[node] = pool.run("demo", node, code, {}, f"demo.{node}", 30)
|
||||
except NodeCancelled as exc:
|
||||
outcome[node] = exc
|
||||
|
||||
sleep = "import time\n\n\ndef process():\n time.sleep(30)\n"
|
||||
ahead = threading.Thread(target=call, args=("ahead", sleep), daemon=True)
|
||||
ahead.start()
|
||||
deadline = time.monotonic() + 10
|
||||
while ("", "demo.ahead") not in pool._running:
|
||||
assert time.monotonic() < deadline, "the first call never started"
|
||||
time.sleep(0.01)
|
||||
queued = threading.Thread(
|
||||
target=call, args=("queued", "def process():\n return 1\n"), daemon=True
|
||||
)
|
||||
queued.start()
|
||||
deadline = time.monotonic() + 5
|
||||
while not pool.cancel("demo.queued"):
|
||||
assert time.monotonic() < deadline, "the queued call was not found"
|
||||
time.sleep(0.01)
|
||||
|
||||
assert pool.cancel("demo.ahead")
|
||||
ahead.join(timeout=10)
|
||||
queued.join(timeout=10)
|
||||
assert isinstance(outcome["queued"], NodeCancelled)
|
||||
assert "waited" in str(outcome["queued"])
|
||||
|
||||
|
||||
def test_a_result_that_is_not_json_is_refused(pool):
|
||||
with pytest.raises(Exception, match="cannot be sent back as JSON"):
|
||||
run(pool, "def process():\n return {'out': {1, 2}}\n")
|
||||
|
||||
Reference in New Issue
Block a user