Skip to main content

Multiprocessing queues for numpy arrays using shared memory

Project description


Build Status Coverage Status PyPI version

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):
        self.source_queue = source_queue

    def run(self):

if __name__ == "__main__":
    q = ArrayQueue(1) # intitialises an ArrayQueue which can hold 1MB of data
    n = np.full((5,5), 5)
    r = ReadProcess(q)

Further examples can be found in tests.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for arrayqueues, version 1.3.1
Filename, size File type Python version Upload date Hashes
Filename, size arrayqueues-1.3.1-py3-none-any.whl (6.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size arrayqueues-1.3.1.tar.gz (8.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page