The uWSGI queue framework¶
In addition to the caching framework, uWSGI includes a shared queue.
At the low level it is a simple block-based shared array, with two optional counters, one for stack-style, LIFO usage, the other one for FIFO.
The array is circular, so when one of the two pointers reaches the end (or the beginning), it is reset. Remember this!
To enable the queue, use the
queue option. Queue blocks are 8 KiB by default. Use
queue-blocksize to change this.
# 100 slots, 8 KiB of data each uwsgi --socket :3031 --queue 100 # 42 slots, 128 KiB of data each uwsgi --socket :3031 --queue 42 --queue-blocksize 131072
Using the queue as a FIFO queue¶
Currently you can only pull, not push. To enqueue an item, use
# Grab an item from the queue uwsgi.queue_pull() # Get the current pull/slot position (this is independent from the stack-based one) print uwsgi.queue_pull_slot()
- You can get the queue size with
- Use the
queue-storeoption to persist the queue on disk. Use
queue-store-sync(in master cycles – usually seconds) to force disk syncing of the queue.
tests/queue.pyapplication is a fully working example.