python-threading-workers
Skill4 starsChanged 2 months agoApache-2.0View on GitHub
Design or debug Python thread/process workers, shared-state synchronization, free-threaded Python behavior, and native thread-pool budgets. Not asyncio-only scheduling or PyO3 module auditing.
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-async-lifecycleSkill
- 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-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 15
Keep lock order consistent.
- Distinctive: line 23
Create native clients, runtimes, connections, and locks inside workers unless a specific cross-process transfer is supported.
- Distinctive: line 31
Read worker checks for version and platform considerations.
≈ “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
Python Threads and Workers
Identify the actual interpreter, GIL runtime state, process start method, native dependencies, and source of parallelism. Decide whether the work is I/O-bound, Python CPU-bound, or native CPU-bound before choosing threads or processes. Existing pools are part of the budget; more workers are not inherently faster.
Shared state and ownership
Protect application invariants across compound operations, not just individual dict/list accesses. Do not use historical GIL behavior or built-in container locks as a transaction guarantee. Prefer explicit ownership, immutable snapshots, queues, or narrow locks. A frozen wrapper does not freeze its contained list or native handle.
Keep lock order consistent. Avoid calling user callbacks while holding non-reentrant locks; snapshot required state and invoke callbacks outside the critical section. Bound submissions, memory, and outstanding results. Define what happens to queued work during cancellation or failure.
For free-threaded execution audit module globals, caches, lazy initialization, iterators, context propagation, and third-party native state. Check the GIL after relevant imports. Separate same-object thread safety from independent-object parallelism. Do not declare subinterpreter support from free-threading evidence; interpreter isolation and module state are different requirements.
Processes and native runtimes
Do not assume fork is the default or a safe shortcut. Inspect the selected platform and Python version. Allow callers to provide an appropriate multiprocessing context instead of globally changing a library user's start method. Worker entry functions and payloads must meet the selected context's serialization/import requirements.
Create native clients, runtimes, connections, and locks inside workers unless a specific cross-process transfer is supported. Do not fork an initialized Tokio or other multithreaded runtime and reuse its inherited handle. Guard application entry points and avoid spawning pools at import time.
Cancellation of an executor Future does not necessarily stop a running function. Provide cooperative cancellation for long work where required; an externally bounded subprocess may be needed for a hard operational boundary. Own worker shutdown and do not rely on daemon threads to flush durable work.
Evidence
Use barriers/events with bounded joins for race tests and fresh processes for hang tests. Stress same-instance and separate-instance access, failure propagation, overload, and repeated create/close. Test the actual GIL-disabled configuration and native host combinations promised by the change. Report CPU/thread counts and untested interpreter isolation claims.
Read worker checks for version and platform considerations.
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.

