Skip to main content

Sometimes when you use the Queue class in Python, you need to get an item from any of several queues. This small module implements an easy solution for this problem.

Project description

Sometimes when you use the Queue class in Python, you need to get an item from any of several queues. This small module implements an easy solution for this problem.

MultiQueue class inherits from Queue and overrides internal methods of data access, sharing its interface but managing multiple queues instead of one.

To add items to a MultiQueue, the put method must receive a tuple with the identifier of the queue as the first element and the value to be stored as the second element.

When getting an item from a MultiQueue, you get a tuple indicating from which queue has been extracted and the extracted value. If there are items in multiple queues, these are obtained mixed, as applying the Round Robin algorithm.

Furthermore, when instantiating the MultiQueue is possible to assign different weights to the queues, so that some have higher priority over others. If you have 2 queues in a MultiQueue, with weights 1 and 10 and both with a large number of elements, in 11 calls to get method you will obtain just one element from the first queue and 10 elements from the second.

Project details


Download files

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

Source Distribution

multiqueue-0.1.6.tar.gz (2.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page