Multiprocessing queues for numpy arrays using shared memory
Project description
ArrayQueues
This package provides a drop-in replacement for the Python multiprocessing Queue class which handles transport of large numpy arrays. It avoids pickling and uses the multiprocessing Array class in the background. The major difference between this implementation and the normal queue is that the maximal amount of memory that the queue can have must be specified beforehand.
Attempting to send an array of a different shape or datatype of the previously inserted one resets the queue. Only passing of numpy arrays is supported, optionally annotated with timestamps if using the TimestampedArrayQueue class, but other object types can be supported by extending the class.
The package has been tested on Python 3.6/3/7 on Windows and MacOS and Linux with Travis. Python 2.7 is not supported.
Usage example
from arrayqueues.shared_arrays import ArrayQueue
from multiprocessing import Process
import numpy as np
class ReadProcess(Process):
def __init__(self, source_queue):
super().__init__()
self.source_queue = source_queue
def run(self):
print(self.source_queue.get())
if __name__ == "__main__":
q = ArrayQueue(1) # intitialises an ArrayQueue which can hold 1MB of data
n = np.full((5,5), 5)
q.put(n)
r = ReadProcess(q)
r.start()
r.join()
Further examples can be found in tests.
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 arrayqueues-1.4.1.tar.gz.
File metadata
- Download URL: arrayqueues-1.4.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec8fb90503bf82cbd34440e405fc6b31b970dc93df638f12e0a2383c218fb456
|
|
| MD5 |
da66faebfca91150e6642029d3d3f944
|
|
| BLAKE2b-256 |
92e8839da8946cfc4f31b758ed4eb5f51e9b189922f801f83b3a89f8b5202d77
|
File details
Details for the file arrayqueues-1.4.1-py3-none-any.whl.
File metadata
- Download URL: arrayqueues-1.4.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea0a5a5e99e0c61dc92f9fc36e29c728b20d68494d51b05578b3217890c7e41d
|
|
| MD5 |
39566a8c70bfc0f902b4f4c3db3efa43
|
|
| BLAKE2b-256 |
032d9d5407501f61521e79449c8dcbb23b6bf38ff10ee9f2323e557e465dadae
|