Utilities for managing threads and processes in a structured way
Project description
Concurrency Group
A library for managing threads and processes in a structured way. It provides the ConcurrencyGroup class which helps avoid accidentally leaking threads and processes, and helps shut them down gracefully.
Key Features
- Track threads and processes created within a context manager
- Ensure proper cleanup and failure handling
- Support nested concurrency groups
- Propagate shutdown events to all threads and processes
- Detect and report timeouts and failures
Basic Usage
from imbue.concurrency_group.concurrency_group import ConcurrencyGroup
with ConcurrencyGroup(name="main") as cg:
# Start a thread
thread = cg.start_new_thread(target=my_function)
# Run a process in the background
process = cg.run_process_in_background(["echo", "hello"])
# Run a process to completion
result = cg.run_process_to_completion(["ls", "-la"])
# All threads and processes are automatically waited for on exit
Nested Groups
with ConcurrencyGroup(name="outer") as outer_cg:
with outer_cg.make_concurrency_group(name="inner") as inner_cg:
inner_cg.start_new_thread(target=my_function)
Shutdown Support
with ConcurrencyGroup(name="main") as cg:
thread = cg.start_new_thread(target=my_function)
# Trigger shutdown of all strands
cg.shutdown()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file concurrency_group-0.1.13.tar.gz.
File metadata
- Download URL: concurrency_group-0.1.13.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6172da72f61f86ee2df6c9a426893a46445e3efe9ede5b62a15928dbc2130db
|
|
| MD5 |
7e8d385f1dc808013989804086cdf7ef
|
|
| BLAKE2b-256 |
ee7299581302977d445fa35ff99bc8c3f3be32dbf783951bedff13f6bdbd7f6e
|
Provenance
The following attestation bundles were made for concurrency_group-0.1.13.tar.gz:
Publisher:
publish.yml on imbue-ai/mngr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
concurrency_group-0.1.13.tar.gz -
Subject digest:
f6172da72f61f86ee2df6c9a426893a46445e3efe9ede5b62a15928dbc2130db - Sigstore transparency entry: 1266404255
- Sigstore integration time:
-
Permalink:
imbue-ai/mngr@ad122299f2a4929360f85c4b1ce4266148092f74 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/imbue-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ad122299f2a4929360f85c4b1ce4266148092f74 -
Trigger Event:
push
-
Statement type:
File details
Details for the file concurrency_group-0.1.13-py3-none-any.whl.
File metadata
- Download URL: concurrency_group-0.1.13-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a6172857a0a8dd033d48bd75b7b076b0023c340aadf6fe39ce87b95db25d706
|
|
| MD5 |
0f5cbe33aaaf4365b4aa23b60c165def
|
|
| BLAKE2b-256 |
57829fc3ab834dd7d6f003981d14da670d085b1913e78f196112f0f4825e724d
|
Provenance
The following attestation bundles were made for concurrency_group-0.1.13-py3-none-any.whl:
Publisher:
publish.yml on imbue-ai/mngr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
concurrency_group-0.1.13-py3-none-any.whl -
Subject digest:
2a6172857a0a8dd033d48bd75b7b076b0023c340aadf6fe39ce87b95db25d706 - Sigstore transparency entry: 1266405245
- Sigstore integration time:
-
Permalink:
imbue-ai/mngr@ad122299f2a4929360f85c4b1ce4266148092f74 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/imbue-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ad122299f2a4929360f85c4b1ce4266148092f74 -
Trigger Event:
push
-
Statement type: