Commit f0bc1ae
committed
Route debug-mode activation via call_soon to fix Python 3.14 task nesting
The prior approach called workflow.activate(act) synchronously from
inside _handle_activation's coroutine. Python 3.14 raised:
RuntimeError: Cannot enter into task <workflow run task>
while another task <_handle_activation> is being executed.
3.14 tightened asyncio's task-step validation: a task cannot be entered
while another task on the same thread is mid-step. Our dispatch task
was mid-step when workflow.activate's internal _run_once tried to step
the workflow's own run task.
Fix: schedule workflow.activate as a `loop.call_soon` callback and
await a future the callback completes. The await suspends the dispatch
task (no longer mid-step), the callback runs as part of the loop's
ready-handle iteration (not inside any task), and the workflow's task
stepping then proceeds with no task currently being stepped.
The main loop is still blocked while the activation runs synchronously,
which is the intended single-stepping debug behavior.
Also drops the temporary 2-minute task_timeout from the test - that was
a wrong-direction guess at a symptom; the real issue was the structural
nested-task error.
Verified locally:
- Python 3.14: all 3 tests pass (previously failed deterministically)
- Python 3.13: all 3 tests pass (regression check)
- tests/worker/test_worker.py: 18 passed, 11 skipped, no regressions1 parent b6efad5 commit f0bc1ae
2 files changed
Lines changed: 51 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
274 | 305 | | |
275 | 306 | | |
276 | 307 | | |
| |||
362 | 393 | | |
363 | 394 | | |
364 | 395 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
375 | 410 | | |
376 | 411 | | |
377 | 412 | | |
| |||
620 | 655 | | |
621 | 656 | | |
622 | 657 | | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
632 | 664 | | |
633 | 665 | | |
634 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | 81 | | |
89 | 82 | | |
90 | 83 | | |
| |||
0 commit comments