Redesign AsyncioWaker around caller-context-independent state transitions
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- rust
- Domain
- backend, testing-qa
Research direction
Start with src/future/asyncio/waker.rs and the runtime attachment check in src/utils.rs, then run the subprocess regressions in python/tests/test_deadlocks.py. Agree on the state-machine design before implementation; done means the listed wake, callback, shutdown, finalization, and subprocess tests define correct behavior without public Python API changes.
Written by the indexing model from the issue text.
Description
Problem and proposed change
AsyncioWaker connects Rust future wakeups to an asyncio.Future. A mutex-protected slot records whether the coroutine is idle, was woken before parking, or is parked on a Python future.
A Rust future can wake:
- synchronously while Python is polling it; or
- later from a detached Tokio worker.
The standard Wake trait does not report which context called it. Current code therefore detects attachment at runtime. Parking also invokes Python event-loop methods while holding the slot mutex. These assumptions make lock ordering, shutdown, and interpreter finalization difficult to reason about.
Redesign the state machine so the mutex protects only short state transitions and ownership moves. Release the mutex before calling Python or destroying Python-owned values. Make wake_by_ref work without detecting caller attachment.
Agree on the design first, then implement it separately.
Context
Current slot states and parking path:
Current explicit wake methods and mixed-context Wake implementation:
Current runtime attachment check:
Existing subprocess regressions:
The same-thread re-entry report #212 was closed as not planned. This proposal is broader structural hardening, not an automatic reopening:
https://github.com/scylladb/python-rs-driver/issues/212
An unconditional Python attachment on every worker wake could hurt performance. Related investigation:
https://github.com/scylladb/python-rs-driver/issues/179
Acceptance criteria
- The slot guard protects only state transitions and ownership moves.
- Python calls and Python-owned-value destruction occur after unlocking.
wake_by_refdoes not need to detect caller attachment.- Wake before, during, and after parking remains correct.
- Tests cover synchronous self-wake and detached worker wake.
- Tests cover callback completion, close, cancel, and exception delivery.
- Task destruction and runtime shutdown behavior are defined.
- Interpreter-finalization behavior is defined if any fallback attaches.
- Potential hangs run in subprocesses with external watchdogs.
- Tests detect lost and duplicate wakeups.
- The worker fast path does not gain unconditional Python attachment without an explicit performance decision.
- No public Python API changes.
- Dominant language
- Rust
- Stars
- 6
- Forks
- 8
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 14
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scylladb/python-rs-driver
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
scylladb/python-rs-driver#224 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
scylladb/python-rs-driver#193 ·
Maintainers usually reply within 4 days
-
Enable manual metadata refreshPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
scylladb/python-rs-driver#158 · 1 comment ·
Maintainers usually reply within 4 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
scylladb/python-rs-driver#233 ·
Maintainers usually reply within 4 days
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
scylladb/python-rs-driver#232 ·
Maintainers usually reply within 4 days
All issues in scylladb/python-rs-driver
Similar issues
-
agent:sonnet-high enhancement priority: P2 ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
shep-pm/shep-kelpie#652 ·
Maintainers usually reply within 1 day
-
install.ps1: Windows PowerShell 5.1 aborts after a successful cosign verification (NativeCommandError on 'Verified OK')Possibly taken @sly321-pixel claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
ai_p2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ClickHouse/ClickHouse#125522 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[Bug]: OpenRouter streaming chunks report the requested router name instead of the model OpenRouter servedPossibly taken @Mrun25 claimed this today. Openbug llm translation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BerriAI/litellm#46095 · 1 comment ·
Maintainers usually reply within 1 day