A project that provides queue-based I/O functionality
Project description
This Python package provides two classes, QueuePipeIO and LimitedQueuePipeIO, that represent queue-based I/O objects. These classes are ideal for multi-threaded or asynchronous programming where data is produced in one thread or coroutine and consumed in another.
Installation
You can install this package from PyPI:
pip install queuepipeio
Usage
Here’s a basic example of how to use QueuePipeIO and LimitedQueuePipeIO:
from queuepipeio import QueuePipeIO, LimitedQueuePipeIO
# Define MB as a constant
MB = 1024 * 1024
# Create a QueuePipeIO object
qpio = QueuePipeIO(chunk_size=8*MB)
# Write data to the queue
qpio.write(b'Hello, world!')
# Close the writer
qpio.close()
# Read data from the queue
data = qpio.read()
print(data) # Outputs: b'Hello, world!'
# Create a LimitedQueuePipeIO object with a memory limit
lqpio = LimitedQueuePipeIO(memory_limit=16*MB, chunk_size=8*MB)
# Write data to the queue
lqpio.write(b'Hello, again!')
# Close the writer
lqpio.close()
# Read data from the queue
data = lqpio.read()
print(data) # Outputs: b'Hello, again!'
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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
queuepipeio-0.1.13.tar.gz
(7.9 kB
view hashes)
Built Distribution
Close
Hashes for queuepipeio-0.1.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5e1816e1324c8ddb95db0eaf07b6c81d1dc4803ee49fa3e3703fc2c5f942d47 |
|
MD5 | 0fd3757ade6aab9f858156a1a1c71e29 |
|
BLAKE2b-256 | c9847c1309593942e11de6641da85fee2e3923e7cca9fa4fb8e5ff83b99bdcb0 |