{ "info": { "author": "Paul Scott, Duedil Limited", "author_email": "paul@duedil.com", "bugtrack_url": null, "classifiers": [], "description": "Python Sloq\n===========\n\nA slower queue implementation, guaranteeing that tasks are processsed at a maximum rate. ``SlowQueue`` aims to be directly comparable with the Queue API so that it can be dropped in as an alternative implementation, as with LIFOQueue and PriorityQueue, but currently (as this needn't be the case) will raise additional ValueErrors if you try to pass ``block=False`` or ``timeout`` > 0 to ``get`` methods. Some slamming is possible and is controllable using the `max_slam` keyword argument on the TokenBucket or SlowQueue instance.\n\nSee following example (taken from demo_sloq.py) or the unit tests for more:\n\n.. code-block:: python\n\n from argparse import ArgumentParser\n from threading import Thread, current_thread\n import logging\n import time\n\n from sloq import SlowQueue\n\n\n def main(args=None):\n prog = ArgumentParser()\n prog.add_argument(\"-n\", type=int, default=10, metavar=\"TASK_COUNT\",\n help=\"The number of tasks\")\n prog.add_argument(\"-t\", type=float, default=1, metavar=\"TASK_INTERVAL\",\n help=\"The tick: seconds between tasks being released\")\n prog.add_argument(\"-w\", type=int, default=3, metavar=\"WORKER_COUNT\",\n help=\"Number of workers\")\n prog.add_argument(\"-d\", type=float, default=0, metavar=\"TASK_DURATION\",\n help=\"Duration of a single task\")\n prog.add_argument(\"-s\", type=float, default=0, metavar=\"MAX_SLAM\",\n help=\"The maximum amount of slam to allow\")\n args = prog.parse_args(args)\n\n logger = logging.getLogger(__name__)\n logger.setLevel(logging.INFO)\n logger.addHandler(logging.StreamHandler())\n\n test_queue(logger, args.t, args.n, args.d, args.w, args.s)\n\n\n def test_queue(logger, tick=1, tasks=10, task_duration=0, worker_count=3,\n slam=0):\n start_time = time.time()\n sloq = SlowQueue(release_tick=tick, max_slam=slam)\n\n # Begin the workers\n for w in xrange(0, worker_count):\n Thread(target=test_worker, args=(logger, start_time, sloq)).start()\n\n # Populate the queue\n for task in xrange(0, tasks):\n sloq.put((task, task_duration))\n for w in xrange(0, worker_count):\n sloq.put((None, None))\n\n sloq.join()\n\n\n def test_worker(logger, start_time, queue):\n while True:\n task, sleep = queue.get()\n if task is None:\n logger.info(\"%s, Done\" % current_thread().name)\n queue.task_done()\n return\n else:\n logger.info(\"%s, Elapsed time: %0.2f, Task: %r\",\n current_thread().name, time.time() - start_time, task)\n if sleep:\n time.sleep(sleep)\n queue.task_done()\n\n\n if __name__ == \"__main__\":\n main()", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/duedil-ltd/python-sloq/tarball/0.2", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/duedil-ltd/python-sloq", "keywords": "queue,rate,limit,slow,token,bucket", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "sloq", "package_url": "https://pypi.org/project/sloq/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/sloq/", "project_urls": { "Download": "https://github.com/duedil-ltd/python-sloq/tarball/0.2", "Homepage": "https://github.com/duedil-ltd/python-sloq" }, "release_url": "https://pypi.org/project/sloq/0.2/", "requires_dist": null, "requires_python": null, "summary": "Rate-limited Queue", "version": "0.2" }, "last_serial": 1115699, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "5798d8dd53ad1b05c162565e1cead605", "sha256": "8f426b639704ef6a718a3bd58b47f31d3501a8de3212a614fd5a84c07fcedfcd" }, "downloads": -1, "filename": "sloq-0.1.tar.gz", "has_sig": false, "md5_digest": "5798d8dd53ad1b05c162565e1cead605", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4099, "upload_time": "2014-06-04T16:41:20", "url": "https://files.pythonhosted.org/packages/8e/5f/7179514070bc0f3a9ef4edb6cf9d1495dd46aac3c55829c8fa30a22bc60c/sloq-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "8533807b56b55fd5622aa2d9c3dd8ede", "sha256": "b85c72e97a80cf13d75107cc9d56a62e7f2d3817c0af262f623b24e7529dba21" }, "downloads": -1, "filename": "sloq-0.2.tar.gz", "has_sig": false, "md5_digest": "8533807b56b55fd5622aa2d9c3dd8ede", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4380, "upload_time": "2014-06-05T14:22:59", "url": "https://files.pythonhosted.org/packages/ce/91/e8be5e739c6c495812a635f0deea9b184c33be02b95c56f0ceada4d3b123/sloq-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8533807b56b55fd5622aa2d9c3dd8ede", "sha256": "b85c72e97a80cf13d75107cc9d56a62e7f2d3817c0af262f623b24e7529dba21" }, "downloads": -1, "filename": "sloq-0.2.tar.gz", "has_sig": false, "md5_digest": "8533807b56b55fd5622aa2d9c3dd8ede", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4380, "upload_time": "2014-06-05T14:22:59", "url": "https://files.pythonhosted.org/packages/ce/91/e8be5e739c6c495812a635f0deea9b184c33be02b95c56f0ceada4d3b123/sloq-0.2.tar.gz" } ] }