{
"info": {
"author": "saaj",
"author_email": "mail@saaj.me",
"bugtrack_url": null,
"classifiers": [
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Topic :: Database",
"Topic :: Software Development :: Libraries"
],
"description": ".. image:: https://bitbucket-badges.atlassian.io/badge/saaj/torrelque.svg?ref=default\r\n :target: https://bitbucket.org/saaj/torrelque/addon/pipelines/home\r\n.. image:: https://codecov.io/bitbucket/saaj/torrelque/branch/default/graph/badge.svg\r\n :target: https://codecov.io/bitbucket/saaj/torrelque/branch/default \r\n.. image:: https://badge.fury.io/py/Torrelque.png\r\n :target: https://pypi.python.org/pypi/Torrelque\r\n\r\n*********\r\nTorrelque\r\n*********\r\n\r\nTorrelque is a Python 3 package that provides a reliable Redis-backed queues and runs on\r\nTornado IO-loop. \r\n\r\nWithout further ado it's easy to say the package is an implementation of the queue described\r\nin `this blog post `_ \r\nwith some required changes and improvements. \r\n\r\nThere's also a related, synchronous queue package called `saferedisqueue \r\n`_. \r\n\r\nInstall\r\n=======\r\n.. sourcecode:: bash\r\n\r\n pip install Torrelque\r\n \r\nUse\r\n===\r\n.. sourcecode:: python\r\n\r\n #!/usr/bin/env python3\r\n \r\n \r\n import random\r\n import logging\r\n \r\n import tornadoredis\r\n from tornado import gen, ioloop\r\n from torrelque import Torrelque\r\n \r\n \r\n logger = logging.getLogger(__name__)\r\n \r\n \r\n @gen.coroutine\r\n def produce():\r\n redis = tornadoredis.Client()\r\n queue = Torrelque(redis, ioloop.IOLoop.current())\r\n while True:\r\n for _ in range(5):\r\n task = {'value': random.randint(0, 99)}\r\n logger.debug('Produced task %s', task)\r\n yield queue.enqueue(task)\r\n yield gen.sleep(10)\r\n \r\n \r\n @gen.coroutine\r\n def process(task_data):\r\n logger.debug('Consmed task %s', task_data)\r\n yield gen.sleep(1)\r\n \r\n @gen.coroutine\r\n def consume():\r\n redis = tornadoredis.Client()\r\n queue = Torrelque(redis, ioloop.IOLoop.current())\r\n while True:\r\n task_id, task_data = yield queue.dequeue()\r\n if not task_id:\r\n continue\r\n try:\r\n yield process(task_data)\r\n yield queue.release(task_id)\r\n except Exception:\r\n logger.exception('Job processing has failed')\r\n yield queue.requeue(task_id, delay = 30)\r\n \r\n @gen.coroutine\r\n def main():\r\n for _ in range(4):\r\n ioloop.IOLoop.current().spawn_callback(consume)\r\n \r\n yield produce()\r\n \r\n \r\n if __name__ == '__main__':\r\n logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s %(message)s')\r\n ioloop.IOLoop.instance().run_sync(main)",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://bitbucket.org/saaj/torrelque",
"keywords": "python tornado redis asynchronous reliable-queue work-queue",
"license": "LGPL-2.1+",
"maintainer": "",
"maintainer_email": "",
"name": "Torrelque",
"package_url": "https://pypi.org/project/Torrelque/",
"platform": "Any",
"project_url": "https://pypi.org/project/Torrelque/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://bitbucket.org/saaj/torrelque"
},
"release_url": "https://pypi.org/project/Torrelque/0.1.2/",
"requires_dist": null,
"requires_python": null,
"summary": "Asynchronous Tornado Redis-based reliable queue package",
"version": "0.1.2"
},
"last_serial": 2903399,
"releases": {
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "e8cee684573ee7be440a3d84e57f8372",
"sha256": "0acebdf8c6b35f62ee82cd3333feec37e385c0a8cd646cfb105ffd92d4415fa7"
},
"downloads": -1,
"filename": "Torrelque-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "e8cee684573ee7be440a3d84e57f8372",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5964,
"upload_time": "2016-01-18T18:52:39",
"url": "https://files.pythonhosted.org/packages/af/16/be9dafa1e902596bb04bab26a6297f0dabb67a66ae2cb8e92ad201e57ff2/Torrelque-0.1.2.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "e8cee684573ee7be440a3d84e57f8372",
"sha256": "0acebdf8c6b35f62ee82cd3333feec37e385c0a8cd646cfb105ffd92d4415fa7"
},
"downloads": -1,
"filename": "Torrelque-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "e8cee684573ee7be440a3d84e57f8372",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5964,
"upload_time": "2016-01-18T18:52:39",
"url": "https://files.pythonhosted.org/packages/af/16/be9dafa1e902596bb04bab26a6297f0dabb67a66ae2cb8e92ad201e57ff2/Torrelque-0.1.2.tar.gz"
}
]
}