concurrent-iterator
Intro
Classes to run producers (iterators) and consumers (coroutines) in a background thread/process.
There are many libraries to create pipelines with stages running in separate processes, a nice one is parallelpipe, but this library does something different. It will lift the entire pipeline up to the point of the Producer into a separate process or thread. It's a more coarse library but easier to integrate since things keep looking as normal generators.
Implementations
There are currently 3 implementations:
dummy.Producer: non-concurrent implementationthread.Producer: uses a background thread to run the generatorprocess.Producer: uses a background process to run the generator
dummy.Producer is useless in practice.
thread.Producer is useful for IO bound generators.
process.Producer is useful for CPU or IO bound generators.
It has the complications of dealing with processes (different memory spaces,
logging, etc).
For logging, module multiprocessing-logging can be used.
Limitations:
process.Producer/process.Consumerwith generators, coroutines and other unpicklable objects require theforkstart method. Python 3.14 changes the default on Linux fromforktoforkserver, andspawn/forkservercannot pickle generators (TypeError: cannot pickle 'generator' object). In those casesprocess.Producernow raisesRuntimeErrorwith a clear message. Usethread.Producer/thread.Consumer, a picklable iterable (e.g.iter([1,2,3])), or forceforkviamultiprocessing.set_start_method('fork', force=True)ormultiprocessing.get_context('fork').Process/Queuewhereforkis available (Linux).
Usage
Basic example:
from concurrent_iterator.thread import Producer
...
items = Producer(slow_generator, maxsize=5)
for item in items:
[Do some time consuming task]
In the previous example, while doing some time consuming task, the
slow_generator will continue running in a background thread and will
pre-calculate up to 5 values.
Metadata
Release files for concurrent-iterator 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| concurrent_iterator-0.4.0.tar.gz | 11.9 kB | Without provenance | Details for concurrent_iterator-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| concurrent_iterator-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for concurrent_iterator-0.4.0-py3-none-any.whl |
Total release size: 23.3 kB
Release files / concurrent_iterator-0.4.0.tar.gz
| Download URL | concurrent_iterator-0.4.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1867853a07779b9f73d1c4b3b8ce2d3277b2234fac6a7cb2cf5562d269fa64e8
|
|
BLAKE2b-256 checksum How to use checksums |
69040957f0f1fdd94fb524a0607ee27bdb82c0e0884752f310204cfaf6c0dac5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.7
|
Release files / concurrent_iterator-0.4.0-py3-none-any.whl
| Download URL | concurrent_iterator-0.4.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0748a2d5c578b153315cf42d0f4b929e55bc71ff3c125af1e2a724a95bcc307d
|
|
BLAKE2b-256 checksum How to use checksums |
25e634fb4cabaca8eb73bcc51b88adcf880850f95e1451ca1df1769dd696ccbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.7
|
Security for concurrent-iterator 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.