Skip to main content

A Queue type for handling traffic that arrives in bursts

Project description

batchqueue

This module provides an extension to the basic queue.Queue class in order to handle situations where incoming data for the queue tends to come in bursts to be processed as a group.

Example Usage:

def worker(queue=None):
    self.assertIsNotNone(queue)

    while True:
        items = queue.get_batch()
        for i in items:
            # Do stuff
            queue.task_done()

# Process a batch any time there's at least a 700ms lull in traffic
self.q = BatchQueue(lull_time=700)

# turn-on the worker thread
threading.Thread(target=worker, daemon=True, kwargs={'queue': self.q}).start()

# send ten task requests to the worker, pausing a random number of
# milliseconds (up to 1000)
for item in range(10):
    sleep(random.randrange(0, 1000) / 1000.0)
    self.q.put(item + 1)

# block until all tasks are done
self.q.join()

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

batchqueue-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

batchqueue-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file batchqueue-0.1.0.tar.gz.

File metadata

  • Download URL: batchqueue-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for batchqueue-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63a89e167db445e91920ebb61857fd831501d2b149d9df9bf1cf7016509d3242
MD5 0fbf78d8e740969920b911f701f1a3e4
BLAKE2b-256 7712fe3d2c672a53528e04806e6723fbdd82d27a478d1942661c81d01c09da81

See more details on using hashes here.

File details

Details for the file batchqueue-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: batchqueue-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for batchqueue-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4de4e7c08f12f8a125606a2475e811fe75effb0b0fbac12ec0645630ec41300f
MD5 2801089582370bace1304e1591e7a010
BLAKE2b-256 d2ceafc5323db6839f84e9e385fdadc4a87bdf6674234db98d8af586282f6097

See more details on using hashes here.

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