Skip to content

Commit

Permalink
Queue options group described.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Jul 8, 2017
1 parent cea0ffb commit d930225
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/source/grp_queue.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Queue
=====

.. automodule:: uwsgiconf.options.queue
:members:
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ API
grp_main_process
grp_master_process
grp_networking
grp_queue
grp_workers
grp_plugin_python
variables
Expand Down
9 changes: 9 additions & 0 deletions tests/options/test_queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from uwsgiconf import Section


def test_queue_basics(assert_lines):

assert_lines([
'queue = 100',
'queue-blocksize = 131072',
], Section().queue.enable(100, block_size=131072))
1 change: 1 addition & 0 deletions uwsgiconf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Section(SectionBase):
main_process = Options(MainProcess) # type: MainProcess
master_process = Options(MasterProcess) # type: MasterProcess
networking = Options(Networking) # type: Networking
queue = Options(Queue) # type: Queue
workers = Options(Workers) # type: Workers

plugin_python = Options(PythonPlugin) # type: PythonPlugin
Expand Down
1 change: 1 addition & 0 deletions uwsgiconf/options/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .main_process import MainProcess
from .master_process import MasterProcess
from .networking import Networking
from .queue import Queue
from .workers import Workers

from .plugins import *
32 changes: 32 additions & 0 deletions uwsgiconf/options/queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ..base import OptionsGroup


class Queue(OptionsGroup):
"""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.
http://uwsgi-docs.readthedocs.io/en/latest/Queue.html
"""

def enable(self, size, block_size=None, store=None, store_sync_interval=None):
"""Enables shared queue of the given size.
:param int size: Queue size.
:param int block_size: Block size in bytes. Default: 8 KiB.
:param str|unicode store: Persist the queue into file.
:param int store_sync_interval: Store sync interval in master cycles (usually seconds).
"""
self._set('queue', size)
self._set('queue-blocksize', block_size)
self._set('queue-store', store)
self._set('queue-store-sync', store_sync_interval)

return self._section

0 comments on commit d930225

Please sign in to comment.