buffered_pipe
Buffered pipe through shared memory.
core features
Pipe: alias forGeneric_PipeGeneric_Pipe: free-length data, bytes or picklableStatic_Pipe: fixed length data, only bytes supported
install
pip install buffered-pipe
usage
- Generic_Pipe
import multiprocessing
import threading
from buffered_pipe import Generic_Pipe
def foo(barrier, pipe_send):
pipe_send.register()
barrier.wait()
pipe_send.send("Hello, world!")
def bar(barrier, pipe_recv):
pipe_recv.register()
barrier.wait()
print(pipe_recv.recv())
if __name__ == "__main__":
barrier = multiprocessing.Barrier(3)
pipe_recv, pipe_send = Generic_Pipe(
buffer_size=2048, duplex=False
)
P = multiprocessing.Process(target=foo, args=(barrier, pipe_send))
T = threading.Thread(target=bar, args=(barrier, pipe_recv))
P.start()
T.start()
barrier.wait()
P.join()
T.join()
- Static_Pipe
import multiprocessing
import threading
from buffered_pipe import Static_Pipe
def foo(barrier, pipe_send):
pipe_send.register()
barrier.wait()
ret_string = "Hello, world!"
ret_string = ret_string + " " * (32 - len(ret_string))
ret_string = ret_string.encode()
pipe_send.send(ret_string)
def bar(barrier, pipe_recv):
pipe_recv.register()
barrier.wait()
ret_string = pipe_recv.recv()
print(ret_string.decode())
if __name__ == "__main__":
barrier = multiprocessing.Barrier(3)
pipe_recv, pipe_send = Static_Pipe(object_size=32, object_count=16, duplex=False)
P = multiprocessing.Process(target=foo, args=(barrier, pipe_send))
T = threading.Thread(target=bar, args=(barrier, pipe_recv))
P.start()
T.start()
barrier.wait()
P.join()
T.join()
- When you create a
processorthread, callregisterofPipe - The
buffer_sizeofGeneric_Pipeis inbytes. - The
object_sizeofStatic_Pipeis inbytes. object_countinStatic_Pipeis the maximum number of objects placed in the buffer.duplexis equivalent tomultiprocessing.Pipe.
tests
> benchmark_result.txt
for f in benchmarks/*.py; do python3 "$f" &>> benchmark_result.txt; done
> test_result.txt
for f in tests/*.py; do python3 "$f" &>> test_result.txt; done
Metadata
Release files for buffered-pipe 0.1.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 |
|---|---|---|---|---|
| buffered_pipe-0.1.0.tar.gz | 11.5 kB | Without provenance | Details for buffered_pipe-0.1.0.tar.gz |
Release files / buffered_pipe-0.1.0.tar.gz
| Download URL | buffered_pipe-0.1.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bebe659c1709c7042fb5dd3a5e6794e634340fc027edec607306e3bdb0d0a6d7
|
|
BLAKE2b-256 checksum How to use checksums |
13ca88ac9ba03ccba7bf74989682e015030e5bbfff40d8160b665390e158f524
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Security for buffered-pipe 0.1.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.