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
File details
Details for the file arrayqueues-1.3.1.tar.gz
.
File metadata
- Download URL: arrayqueues-1.3.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a955df768e39d459de28c7ea10ee02f67b1c70996cfa229846ab98df77a6fb69 |
|
MD5 | 3fc882754d8ebf90099047d98d16fa00 |
|
BLAKE2b-256 | d64bb8bcbf73758b9125f5368a7e8482195a82b866510b6279088582bb2db782 |
File details
Details for the file arrayqueues-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: arrayqueues-1.3.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c338da757abfa980d5cf321af5a24910088fb7a02d97eb45f676ef7b02e23d4 |
|
MD5 | c7c33296de8a713afaa71fe261ec7692 |
|
BLAKE2b-256 | c05d8b813744f4388c57efa30fcf1e1c9370c653739a26c1c1ab32241a114643 |