{ "info": { "author": "Daniel Miller", "author_email": "millerdev@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "\n========================\nWorQ - Python task queue\n========================\n\nWorQ is a Python task queue that uses a worker pool to execute tasks in\nparallel. Workers can run in a single process, multiple processes on a single\nmachine, or many processes on many machines. It ships with two backend options\n(memory and redis) and two worker pool implementations (multi-process and\nthreaded). Task results can be monitored, waited on, or passed as arguments to\nanother task.\n\nWorQ has two main components:\n\n* ``TaskQueue``\n* ``WorkerPool``\n\nWorQ ships with more than one implementation of each of these components.\n\n* ``worq.queue.memory.TaskQueue`` - an in-memory (process local) task queue.\n\n* ``worq.queue.redis.TaskQueue`` - a Redis-backed task queue that can scale\n to multiple servers.\n\n* ``worq.pool.thread.WorkerPool`` - a multi-thread worker pool.\n\n* ``worq.pool.process.WorkerPool`` - a multi-process worker pool.\n\nThese components can be mixed and matched as desired to meet the needs of your\napplication. For example, an in-memory task queue can be used with a multi-\nprocess worker pool to to execute truely concurrent Python tasks on a single\nmulti-core machine.\n\n\nAn example with Redis and a multi-process worker pool\n=====================================================\n\nCreate the following files.\n\n``tasks.py``::\n\n import logging\n from worq import get_broker, TaskSpace\n\n ts = TaskSpace(__name__)\n\n def init(url):\n logging.basicConfig(level=logging.DEBUG)\n broker = get_broker(url)\n broker.expose(ts)\n return broker\n\n @ts.task\n def num(value):\n return int(value)\n\n @ts.task\n def add(values):\n return sum(values)\n\n``pool.py``::\n\n #!/usr/bin/env python\n import sys\n from worq.pool.process import WorkerPool\n from tasks import init\n\n def main(url, **kw):\n broker = init(url)\n pool = WorkerPool(broker, init, workers=2)\n pool.start(**kw)\n return pool\n\n if __name__ == '__main__':\n main(sys.argv[-1])\n\n``main.py``::\n\n #!/usr/bin/env python\n import sys\n import logging\n from worq import get_queue\n\n def main(url):\n logging.basicConfig(level=logging.DEBUG)\n q = get_queue(url)\n\n # enqueue tasks to be executed in parallel\n nums = [q.tasks.num(x) for x in range(10)]\n\n # process the results when they are ready\n result = q.tasks.add(nums)\n\n # wait for the final result\n result.wait(timeout=30)\n\n print('0 + 1 + ... + 9 = {}'.format(result.value))\n\n if __name__ == '__main__':\n main(sys.argv[-1])\n\nMake sure Redis is accepting connections on port 6379. It is recommended, but\nnot required, that you setup a virtualenv. Then, in a terminal window::\n\n $ pip install \"WorQ[redis]\"\n $ python pool.py redis://localhost:6379/0\n\nAnd in a second terminal window::\n\n $ python main.py redis://localhost:6379/0\n\nTasks may also be queued in in memory rather than using Redis. In this case\nthe queue must reside in the same process that initiates tasks, but the work\ncan still be done in separate processes. For example:\n\n\nExample with memory queue and a multi-process worker pool\n=========================================================\n\nIn addition to the three files from the previous example, create the following:\n\n``mem.py``::\n\n #!/usr/bin/env python\n import main\n import pool\n\n if __name__ == \"__main__\":\n url = \"memory://\"\n p = pool.main(url, timeout=2, handle_sigterm=False)\n try:\n main.main(url)\n finally:\n p.stop()\n\nThen, in a terminal window::\n\n $ python mem.py\n\n\nSee `examples.py` for more things that can be done with WorQ.\n\n\nLinks\n=====\n\n* Documentation: http://worq.readthedocs.org/\n* Source: https://github.com/millerdev/WorQ/\n* PyPI: http://pypi.python.org/pypi/WorQ\n\n\nRunning the tests\n=================\n\nWorQ development is mostly done using TDD. Tests are important to verify that\nnew code works. You may want to run the tests if you want to contribute to WorQ\nor simply just want to hack. Setup a virtualenv and run these commands where you\nhave checked out the WorQ source code::\n\n $ pip install nose\n $ nosetests\n\nThe tests for some components (e.g., redis TaskQueue) are disabled unless\nthe necessary requirements are available. For example, by default the tests\nlook for redis at ``redis://localhost:16379/0`` (note non-standard port; you\nmay customize this url with the ``WORQ_TEST_REDIS_URL`` environment variable).\n\n\n==========\nChange Log\n==========\n\nv1.1.1, 2018-03-20\n - Add example using memory queue\n - Fix python 3 compatibility\n\nv1.1.0, 2014-03-29\n - Add support for Python 3\n\nv1.0.2, 2012-09-07\n - Allow clearing entire Queue with ``del queue[:]``.\n - Raise ``DuplicateTask`` (rather than the more generic ``TaskFailure``) when\n trying to enqueue a task with an id matching that of another task in the\n queue.\n\nv1.0.1, 2012-09-06\n - Better support for managing more than one process.WorkerPool with a single\n pool manager process.\n - Queue can be created with default task options.\n - Can now check the approximate number of tasks in the queue with len(queue).\n - Allow passing a completed Deferred as an argument to another task.\n - Fix redis leaks.\n\nv1.0.0, 2012-09-02 -- Initial release.\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://worq.readthedocs.org/", "keywords": "", "license": "LICENSE.txt", "maintainer": "", "maintainer_email": "", "name": "WorQ", "package_url": "https://pypi.org/project/WorQ/", "platform": "", "project_url": "https://pypi.org/project/WorQ/", "project_urls": { "Homepage": "http://worq.readthedocs.org/" }, "release_url": "https://pypi.org/project/WorQ/1.1.1/", "requires_dist": [ "redis (>=2.4); extra == 'redis'" ], "requires_python": "", "summary": "Python task queue", "version": "1.1.1" }, "last_serial": 3689775, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "a9292393ce621f0fd9b7c05e85ce0d58", "sha256": "40545c131a5476b5b781d0b8c581b50f2ce3ce745e8ca85aa4e850f38ce2ef32" }, "downloads": -1, "filename": "WorQ-1.0.tar.gz", "has_sig": false, "md5_digest": "a9292393ce621f0fd9b7c05e85ce0d58", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26626, "upload_time": "2012-09-03T05:17:26", "url": "https://files.pythonhosted.org/packages/43/16/94e9934e61993dfaec8e427cdee3db26d58008a3ab6fd35aa023c05c277e/WorQ-1.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "7bf5b3149e82b599400f680cd521233b", "sha256": "c37b711d78e7a066b627c96833d67d981c8517b812421aacf58224e8f5dbc339" }, "downloads": -1, "filename": "WorQ-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7bf5b3149e82b599400f680cd521233b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33120, "upload_time": "2012-09-03T20:43:37", "url": "https://files.pythonhosted.org/packages/2e/10/7f2a9e4b3a043e691f2c725376c22219ed07cd8dff1e4d753fa3352d03a5/WorQ-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "34fea71eca35077412fada346695ed63", "sha256": "c4e01575997cb01c38e2a2dc5cf4cc073aa014826543673158573003cc5cea84" }, "downloads": -1, "filename": "WorQ-1.0.1.tar.gz", "has_sig": false, "md5_digest": "34fea71eca35077412fada346695ed63", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35335, "upload_time": "2012-09-07T02:29:34", "url": "https://files.pythonhosted.org/packages/84/d5/7e7cea7ee2ae72441479a973a47dd9070aebddbcbe312cc9e8444ea22a1f/WorQ-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "50da029d88adcab7c981f43c033aad84", "sha256": "daa54ae965eac8263e9cf98a02176120e8bfae7137ebcaf131bd83036afa949d" }, "downloads": -1, "filename": "WorQ-1.0.2.tar.gz", "has_sig": false, "md5_digest": "50da029d88adcab7c981f43c033aad84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35622, "upload_time": "2012-09-07T19:00:28", "url": "https://files.pythonhosted.org/packages/77/27/1d5d10b435515c17bd7c68a70b3a601e4db50bec4fcdc2f0792c145efb65/WorQ-1.0.2.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "5b57ebaf8a8178b7cd668d4d3a672324", "sha256": "a46df66b2c3881ad794040bc878067118be01a245b7f61074cdc3ee94613c812" }, "downloads": -1, "filename": "WorQ-1.1.0.tar.gz", "has_sig": false, "md5_digest": "5b57ebaf8a8178b7cd668d4d3a672324", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36526, "upload_time": "2014-03-29T15:17:37", "url": "https://files.pythonhosted.org/packages/b5/a9/018ca3b64e1601940ace2b3f1a81db3deb14cf3bce6651c202c865a7be50/WorQ-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "c2933e52a4b237fc77d6daa1f0492214", "sha256": "4e75fc4b8bcbc8d05fdf14e33647d6f6fb2d7faac7f379951d852a40c14e3c99" }, "downloads": -1, "filename": "WorQ-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c2933e52a4b237fc77d6daa1f0492214", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 40927, "upload_time": "2018-03-21T01:01:06", "url": "https://files.pythonhosted.org/packages/8d/47/2da6fda6e2f0fb44cedc90a9052b8f030225ff2df52086851564369b0106/WorQ-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2ee474f804107ac55610f4b4947ab441", "sha256": "a102ff8ee5f1b4a47bf2f5a80fe3a28745bc13d88fec9f3c77cf3fb0175eda62" }, "downloads": -1, "filename": "WorQ-1.1.1.tar.gz", "has_sig": false, "md5_digest": "2ee474f804107ac55610f4b4947ab441", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36985, "upload_time": "2018-03-21T01:01:08", "url": "https://files.pythonhosted.org/packages/5b/ec/c706e66df0ad1540428e4c86349ed5a855109fb5c050c19ec4eaa1bba475/WorQ-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2933e52a4b237fc77d6daa1f0492214", "sha256": "4e75fc4b8bcbc8d05fdf14e33647d6f6fb2d7faac7f379951d852a40c14e3c99" }, "downloads": -1, "filename": "WorQ-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c2933e52a4b237fc77d6daa1f0492214", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 40927, "upload_time": "2018-03-21T01:01:06", "url": "https://files.pythonhosted.org/packages/8d/47/2da6fda6e2f0fb44cedc90a9052b8f030225ff2df52086851564369b0106/WorQ-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2ee474f804107ac55610f4b4947ab441", "sha256": "a102ff8ee5f1b4a47bf2f5a80fe3a28745bc13d88fec9f3c77cf3fb0175eda62" }, "downloads": -1, "filename": "WorQ-1.1.1.tar.gz", "has_sig": false, "md5_digest": "2ee474f804107ac55610f4b4947ab441", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36985, "upload_time": "2018-03-21T01:01:08", "url": "https://files.pythonhosted.org/packages/5b/ec/c706e66df0ad1540428e4c86349ed5a855109fb5c050c19ec4eaa1bba475/WorQ-1.1.1.tar.gz" } ] }