pyo3-async-lifecycle
Skill4 starsChanged 2 months agoApache-2.0View on GitHub
Use for pyo3-async-runtimes, Tokio/asyncio bridges, synchronous wrappers over async Rust, callbacks, cancellation, and close/drop behavior. Not generic async Python with no native boundary.
In this repository81 other files it gives its agents.
- agent-cli-designSkill
- agent-tool-boundariesSkill
- behavior-first-implementationSkill
- bounded-prototypeSkill
- bounded-pr-sliceSkill
- building-fdd-validationSkill
- context-efficiencySkill
- cross-language-contractsSkill
- cross-platform-agent-instructionsSkill
- design-interviewSkill
- diagnosis-loopSkill
- domain-languageSkill
- edge-cloud-syncSkill
- handoff-continuitySkill
- immutable-pr-reviewSkill
- memory-context-hygieneSkill
- module-designSkill
- orchestrateSkill
- owner-decision-gateSkill
- parallel-portfolioSkill
- pr-gate-loopSkill
- pyo3-buffer-performanceSkill
- pyo3-free-threadingSkill
- pyo3-ownership-errorsSkill
- pyo3-wheel-releaseSkill
- python-api-typingSkill
- python-async-concurrencySkill
- python-ci-releaseSkill
- python-data-boundariesSkill
- python-packaging-environmentsSkill
- python-performanceSkill
- python-pytestSkill
- python-reviewSkill
- python-test-designSkill
- python-threading-workersSkill
- python-workflowSkill
- react-components-stateSkill
- react-performanceSkill
- repository-groundingSkill
- rust-api-designSkill
- rust-async-concurrencySkill
- rust-build-diagnosticsSkill
- rust-ci-releaseSkill
- rust-memory-layoutSkill
- rust-nextestSkill
- rust-numerics-simdSkill
- rust-performanceSkill
- rust-protocol-codecsSkill
- rust-python-bindingsSkill
- rust-reviewSkill
- rust-storage-durabilitySkill
- rust-test-designSkill
- rust-unsafe-ffiSkill
- rust-workflowSkill
- rust-workspace-dependenciesSkill
- shadcn-react-componentsSkill
- shadcn-svelte-componentsSkill
- simplify-existing-codeSkill
- source-verificationSkill
- svelte-components-runesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Read the installed pyo3-async-runtimes/PyO3 APIs and trace ownership across the Python loop, Tokio runtime, native client, task handles, …
- Distinctive: line 25
Treat context propagation deliberately.
- Distinctive: line 29
Test normal completion, Python cancellation, native error, close with in-flight work, repeated close, callback exception/reentry, multiple …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PyO3 Async Lifecycle
Read the installed pyo3-async-runtimes/PyO3 APIs and trace ownership across the Python loop, Tokio runtime, native client, task handles, and Python object. Reuse the repository's bridge; do not create a new runtime per request or nest runtime drivers indiscriminately.
Define the lifecycle before editing
Identify who starts the runtime, admits operations, retains in-flight work, rejects new work during close, drains/cancels remaining work, joins tasks, and finally destroys the runtime. Separate graceful asynchronous close, immediate non-waiting abort, final object drop, and interpreter exit. A destructor cannot be assumed to await cleanup or run on a convenient thread.
Python awaitables and asyncio objects belong to their loop. Do not create bridge futures during import or before the intended loop exists, cache them across loops, or invoke asyncio.run inside an already-running loop. A bridge can return an asyncio Future: do not label every awaitable as a coroutine or assume create_task accepts it on all supported Python versions. Native workers must dispatch into the Python loop through the bridge or documented thread-safe facilities.
Clone the required native ownership and release temporary Python/pyclass borrows before crossing an await. Keep synchronous Rust waits detached from Python when the pinned API permits it. Detach does not resolve wrong-thread runtime destruction, unsupported nested block_on, or callbacks under a core mutex.
Follow cancellation all the way down
The documented future_into_py bridge propagates Python Future cancellation to its wrapped Rust future. Determine what dropping that future actually cancels. Separately spawned tasks, blocking work, transport sends, and committed database writes may continue. Preserve protocol identity and cleanup guards; never describe a timeout as proof that no external side effect happened or retry a write blindly.
Use one close deadline, stop admission before draining, and keep response/timeout processing alive while needed. Make repeated close and abort-after-close behavior explicit. Ensure cancellation during close does not leak the runtime or leave hidden admitted work. Do not shield entire operations just to make cancellation tests green.
Treat context propagation deliberately. The bridge documents contextvars handling for converted asynchronous Python calls; synchronous callbacks from Rust do not automatically inherit that context. Use the documented explicit context mechanism where required and test it rather than depending on thread-local coincidence.
Validate the seam
Test normal completion, Python cancellation, native error, close with in-flight work, repeated close, callback exception/reentry, multiple supported event loops, and interpreter/process exit. Bound hang-prone cases with a supervising subprocess. Recheck task/permit/socket cleanup, not just the awaited exception.
Report the operation and teardown contract, surviving work after cancellation, commands, and untested runtime/interpreter cases.
Read lifecycle cases.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

