Skip to content

QueueBytesIO: A Python package providing a BytesIO-like interface with a queue for efficient handling of data streams. Ideal for multi-threaded or asynchronous programming where data is produced in one thread or coroutine and consumed in another.

License

Notifications You must be signed in to change notification settings

dangeReis/QueuePipeIO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QueueIO and LimitedQueueIO

This Python package provides two classes, QueueIO and LimitedQueueIO, 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 queue_bytes_io

Usage

Here's a basic example of how to use QueueIO and LimitedQueueIO:

from queuebytesio import QueueIO, LimitedQueueIO

# Define MB as a constant
MB = 1024 * 1024

# Create a QueueIO object
qbio = QueueIO(chunk_size=8*MB)

# Write data to the queue
qbio.write(b'Hello, world!')

# Close the writer
qbio.close()

# Read data from the queue
data = qbio.read()

print(data)  # Outputs: b'Hello, world!'

# Create a LimitedQueueIO object with a memory limit
lqbio = LimitedQueueIO(memory_limit=16*MB, chunk_size=8*MB)

# Write data to the queue
lqbio.write(b'Hello, again!')

# Close the writer
lqbio.close()

# Read data from the queue
data = lqbio.read()

print(data)  # Outputs: b'Hello, again!'

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

QueueBytesIO: A Python package providing a BytesIO-like interface with a queue for efficient handling of data streams. Ideal for multi-threaded or asynchronous programming where data is produced in one thread or coroutine and consumed in another.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages