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.

Files for multiqueue, version 0.1.6
Filename, size File type Python version Upload date Hashes
Filename, size multiqueue-0.1.6.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page