{ "info": { "author": "xutaozhe", "author_email": "xutaozhe@zopen.cn", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "ZTQ\uff1aZopen Task Queue\n===========================================\n\n\u7b80\u4ecb\n--------------------\n\nZTQ \u961f\u5217\u670d\u52a1, \u5206\u4e3a3\u4e2a\u5305\uff1aztq_core, ztq_worker, ztq_console\u3002\u9ed8\u8ba4\u4f7f\u7528redis\u4f5c\u4e3a\u961f\u5217\u7684\u540e\u7aef\u3002\n\nztq_core ::\n\n \u63d0\u4f9b\u4e00\u7cfb\u5217\u7684\u65b9\u6cd5\u628a\u4efb\u52a1push\u5230\u961f\u5217\u4e2d\uff0c\u7531ztq_worker\u53bb\u83b7\u53d6\u961f\u5217\u4efb\u52a1\u5e76\u4e14\u6267\u884c\u3002\n\n\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\u5b83\uff1a http://pypi.python.org/pypi/ztq_core/\n\nztq_worker::\n\n \u961f\u5217\u7684\u63a5\u6536\u7aef\uff0c\u4ee5\u7ebf\u7a0b\u4e3a\u5355\u4f4d\u963b\u585e\u5f0f\u7684\u53bb\u76d1\u89c6\u4e00\u4e2a\u961f\u5217\u3002\u6bcf\u4e00\u4e2a\u7ebf\u7a0b\u79f0\u4e3aWorker\n \u5f53\u6709\u4efb\u52a1push\u5230\u4e86\u961f\u5217\u4e2d\uff0c\u76f8\u5e94\u7684Worker\u4f1a\u81ea\u52a8pull\u4e0b\u6765\u53bb\u6267\u884c\u3002\n\n\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\u5b83\uff1a http://pypi.python.org/pypi/ztq_worker/\n\nztq_console::\n\n \u5bf9\u6bcf\u4e00\u4e2a\u961f\u5217\u7684\u6bcf\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u60c5\u51b5\u8fdb\u884c\u76d1\u63a7\u3001\u4e0b\u8fbe\u6307\u4ee4\u3002\u8fd9\u4e2a\u5305\u662f\u53ef\u9009\u7684\n\n\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\u5b83\uff1a http://pypi.python.org/pypi/ztq_console/\n\n\u5173\u4e8e ZTQ \n--------------------\n:: \n\n * \u5f00\u6e90, \u4f7f\u7528MIT \u8bb8\u53ef\n * \u57fa\u4e8ePython, \u5bb9\u6613\u4f7f\u7528\u548c\u4fee\u6539\n * \u652f\u6301linux \u548c windows\n * \u53ef\u9760\uff0c\u53ef\u4ee5\u5e94\u4ed8\u7a81\u7136\u65ad\u7535\u7b49\u60c5\u51b5\n * \u53ef\u7ba1\u7406\uff0c\u81ea\u8eab\u5e26\u6709ztq_console \u76d1\u63a7\u540e\u53f0\n * \u7075\u6d3b\uff0c\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\u8fd0\u884c\u591a\u4e2aWorker, \u5e76\u4e14\u968f\u65f6\u70ed\u63d2\u62d4Worker \n * \u4f7f\u7528\u7b80\u5355\n\n\u5b89\u88c5\n--------------------\n::\n\n pip install ztq_core\n pip install ztq_worker\n pip install ztq_console\n\n\u4f7f\u7528\n-------------------\n\n#. \u5148\u5b9a\u4e49\u4e00\u4e2a\u666e\u901a\u7684\u4efb\u52a1 ::\n\n # my_send.py\n\n def send(body):\n print \u2018START: \u2018, body\n sleep(5)\n print \u2018END:\u2019, body\n\n\n def send2(body):\n print \u2018START2\u2019, body\n raise Exception(\u2018connection error\u2019)\n\n \n#. \u5c06\u666e\u901a\u7684\u4efb\u52a1\u6539\u6210\u961f\u5217\u4efb\u52a1 ::\n\n # my_send.py\n\n import time\n from ztq_core import async\n\n @async # \u4f7f\u7528\u9ed8\u8ba4\u961f\u5217default\n def send(body):\n print \u2018START: \u2018, body\n sleep(5)\n print \u2018END:\u2019, body\n\n @async(queue=\u2018mail\u2019) # \u4f7f\u7528\u961f\u5217mail\n def send(body):\n print \u2018START2\u2019, body\n raise Exception(\u2018connection error\u2019)\n\n\n#. \u8fd0\u884cworker ::\n\n # \u8fd0\u884c\uff1abin/ztq_worker app.ini\n\n # app.ini \u4f8b\u5b50, \u5728ztq_worker \u5305\u91cc\u9762\u6709\u4e2aconfig \u76ee\u5f55\u653e\u6709app.ini \u8fd9\u4e2a\u6587\u4ef6\n\n [server]\n host = localhost\n port = 6379\n db = 0\n alias = w01\n active_config = false\n modules = my_send # \u6240\u6709\u9700\u8981import\u7684\u4efb\u52a1\u6a21\u5757\uff0c\u6bcf\u4e2a\u4e00\u884c\n\n [queues]\n default= 0 # default\u961f\u5217\uff0c\u8d771\u4e2a\u5904\u7406\u7ebf\u7a0b\n mail = 0, 0 # mail\u961f\u5217\uff0c\u8d772\u4e2a\u5904\u7406\u7ebf\u7a0b\n\n [log]\n handler_file = ./ztq_worker.log\n level = ERROR\n\n#. \u8fd0\u884c ::\n\n import ztq_core\n from my_send import send\n\n # \u8bbe\u7f6e Redis \u8fde\u63a5\n ztq_core.setup_redis(\u2018default\u2019, \u2018localhost\u2019, 6379, 0)\n\n send(\u2018hello, world\u2019)\n\n # \u52a8\u6001\u6307\u5b9aqueue\n send(\u2018hello world from mail\u2019, ztq_queue=\u2018mail\u2019)\n\n#. \u66f4\u8be6\u7ec6\u7684\u6d4b\u8bd5\u4f8b\u5b50\u53ef\u89c1ztq_core\u5305\u4e0b\u7684demo.py\n\n\u4f7f\u7528\u66f4\u9ad8\u7ea7\u7684\u7279\u5f81\n--------------------------\n\n#. \u62a2\u5360\u5f0f\u6267\u884c ::\n\n # \u540e\u63d2\u5165\u5148\u6267\u884c\u3002\u5982\u679c\u4efb\u52a1\u5df2\u7ecf\u5728\u961f\u5217\uff0c\u4f1a\u4f18\u5148\n send (body, ztq_first=True) \n\n#. \u63a2\u6d4b\u4efb\u52a1\u72b6\u6001 ::\n\n # ztq_first\u5b58\u5728\u5c31\u4f18\u5148, ztq_run\u4e0d\u5b58\u5728\u5c31\u8fd0\u884c\n # \u8fd4\u56de\u7684\u662f\"running\" \u4ee3\u8868\u6b63\u5728\u8fd0\u884c, \u662f\"queue\" \u4ee3\u8868\u6b63\u5728\u6392\u961f\n # \u5982\u679c\u662f\"error\" \u4ee3\u8868\u51fa\u9519, \u662f\"none\" \u4ee3\u8868\u8fd9\u4e2a\u4efb\u52a1\u4e0d\u5728\u6392\u961f\uff0c\u4e5f\u6ca1\u5728\u6267\u884c\n ping_task(send, body, ztq_first=True, ztq_run=True)\n\n#. \u652f\u6301\u4e8b\u52a1 ::\n\n import transaction\n ztq_core.enable_transaction(True)\n send_mail(from1, to1, body1)\n send_mail(from2, to2, body2)\n transaction.commit()\n # \u4e5f\u53ef\u4ee5\u5355\u72ec\u5173\u95ed\u4e8b\u52a1\n send_mail(from2, to2, body2, ztq_transaction=False)\n\n#. \u5b9a\u65f6\u4efb\u52a1 ::\n \n from ztq_core.async import async\n from ztq_core import redis_wrap\n from ztq_core.cron import has_cron, add_cron_job\n\n @async(queue='clock-0')\n def bgrewriteaof():\n \"\"\" \u5c06redis\u7684AOF\u6587\u4ef6\u538b\u7f29 \"\"\"\n redis = redis_wrap.get_redis()\n redis.bgrewriteaof()\n\n\n # \u5982\u679c\u961f\u5217\u4e0a\u6ca1\u6709\u8fd9\u4e2a\u5b9a\u65f6\u4efb\u52a1\uff0c\u5c31\u52a0\u4e0a\u3002\u81ea\u52a8\u5b9a\u65f6\u538b\u7f29reids\n if not has_cron(bgrewriteaof):\n add_cron({'hour':1}, bgrewriteaof)\n\n#. \u4efb\u52a1\u4e32\u884c ::\n\n from ztq_core import prepare_task\n # \u6839\u636e(\u65b9\u6cd5\uff0c\u53c2\u6570)\u751f\u6210\u4e00\u4e2a\u4efb\u52a1\n callback = prepare_task(send, body)\n # \u6267\u884c\u5b8c send_mail \u4e4b\u540e\u961f\u5217\u4f1a\u81ea\u52a8\u5c06callback \u653e\u5165\u6307\u5b9a\u7684\u961f\u5217\n send_mail(body, ztq_callback=callback)\n\n#. \u5f02\u5e38\u5904\u7406 ::\n\n from ztq_core import prepare_task\n\n @async(queue='mail')\n def fail_callback(return_code, return_msg):\n print return_code, return_msg\n\n fcallback = prepare_task(send2)\n\n # \u5982\u679c\u4efb\u52a1 send \u629b\u51fa\u4e86\u4efb\u4f55\u5f02\u5e38\uff0c\u90fd\u4f1a\u5c06fcallback \u653e\u5165\u6307\u5b9a\u961f\u5217\n send(body, ztq_fcallback=fcallback)\n\n#. \u8fdb\u5ea6\u56de\u8c03 ::\n\n import ztq_worker\n @async(queue='doc2pdf')\n def doc2pdf(filename):\n ...\n # \u53ef\u88ab\u8fdb\u5ea6\u56de\u8c03\u51fd\u6570\u8c03\u7528\n ztq_worker.report_progress(page=2)\n ...\n\n from ztq_core import prepare_task\n pcallback = prepare_task(send2, body)\n doc2pdf(filename, ztq_pcallback=pcallback)\n\n#. \u6279\u5904\u7406 ::\n\n # \u4e3a\u63d0\u5347\u6027\u80fd\uff0c\u9700\u8981\u591a\u4e2axapian\u7d22\u5f15\u64cd\u4f5c\uff0c\u4e00\u6b21\u6027\u63d0\u4ea4\u6570\u636e\u5e93\n @async(queue=\u2018xapian\u2019)\n def index(data):\n pass\n\n def do_commit(): \n xapian_conn.commit()\n\n # \u6bcf\u6267\u884c20\u4e2a\u7d22\u5f15\u4efb\u52a1\u4e4b\u540e\uff0c\u4e00\u6b21\u6027\u63d0\u4ea4\u6570\u636e\u5e93\n # \u4e0d\u591f20\u4e2a\uff0c\u4f46\u961f\u5217\u7a7a\u7684\u65f6\u5019\uff0c\u4e5f\u4f1a\u63d0\u4ea4\n register_batch_queue(\u2018xapian\u2019, 20, batch_func=do_commit)\n\n\n\n1.0dev\n---\n\n- Initial version", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "Everydo queue async ztq_worker", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "ztq_worker", "package_url": "https://pypi.org/project/ztq_worker/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ztq_worker/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/ztq_worker/1.3.2/", "requires_dist": null, "requires_python": null, "summary": "Zopen Task Queue Worker", "version": "1.3.2" }, "last_serial": 1552562, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "3381c5dd4356e86dc3802fea25a83c36", "sha256": "eff3f7be3fd3e3e7c2cbd3d04b6b57bc50fd383b2344c3968a29e0c8de561a98" }, "downloads": -1, "filename": "ztq_worker-1.0.tar.gz", "has_sig": false, "md5_digest": "3381c5dd4356e86dc3802fea25a83c36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12002, "upload_time": "2014-01-16T01:46:23", "url": "https://files.pythonhosted.org/packages/d9/71/520566ebe0ce124400d94ab3a1c7e18b05e35e0bc89b9d1d3f0cc0412833/ztq_worker-1.0.tar.gz" } ], "1.0.1dev": [ { "comment_text": "", "digests": { "md5": "64adb026b56b61434dd12740052ec4af", "sha256": "5e03ff9a55a028d7ffe6a62bb0e23e46ad8e63514e583725eab6fd8d0430d7fc" }, "downloads": -1, "filename": "ztq_worker-1.0.1dev.tar.gz", "has_sig": false, "md5_digest": "64adb026b56b61434dd12740052ec4af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12592, "upload_time": "2012-10-22T04:01:59", "url": "https://files.pythonhosted.org/packages/81/0b/2377e3ae9ac077fc2f552513e8a1e3b9f46b42a84be73f99d783fa7fddbd/ztq_worker-1.0.1dev.tar.gz" } ], "1.0dev": [ { "comment_text": "", "digests": { "md5": "5ede6aaa04640261bb097ff95ed57d4f", "sha256": "d5ed762221e0b3f5a606d0352dbd4e7047c40091f3c47387629a8ce0664b76e8" }, "downloads": -1, "filename": "ztq_worker-1.0dev.tar.gz", "has_sig": false, "md5_digest": "5ede6aaa04640261bb097ff95ed57d4f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12049, "upload_time": "2012-10-20T17:09:44", "url": "https://files.pythonhosted.org/packages/7e/5e/dd200cffd5851c41cd1d98619df95615d2314099964b7ce72d95504d23ce/ztq_worker-1.0dev.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "875aa7084877464aee03173c291fb879", "sha256": "e0edb3c0440fbe2352b9f7ad13d0b2c647c05df9a02079296c318e1f294fc376" }, "downloads": -1, "filename": "ztq_worker-1.1.tar.gz", "has_sig": false, "md5_digest": "875aa7084877464aee03173c291fb879", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12004, "upload_time": "2014-01-16T01:46:50", "url": "https://files.pythonhosted.org/packages/03/0e/5e14cb8303367755216601a5df617e92ffbc414dfd3380d66a60fd4dd569/ztq_worker-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "df52c13782c5ac0457656a3ac8591917", "sha256": "c10389e9798eceb713b1f6aa1d7351025a07cded5b17e79e9f037676933e94b3" }, "downloads": -1, "filename": "ztq_worker-1.2.tar.gz", "has_sig": false, "md5_digest": "df52c13782c5ac0457656a3ac8591917", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16125, "upload_time": "2014-01-16T05:30:36", "url": "https://files.pythonhosted.org/packages/22/31/fee6cfe6d803645b63cb1794d30c9a029c01fd02e61d7ce5a05f3a2fd309/ztq_worker-1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "d71fa3210005720ba97589fa3310675d", "sha256": "118683ca6fe61ad0adefd7fede3c36ea391d4d6689869a40ddabe2fdb3c9e923" }, "downloads": -1, "filename": "ztq_worker-1.2.1.tar.gz", "has_sig": false, "md5_digest": "d71fa3210005720ba97589fa3310675d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16240, "upload_time": "2014-02-13T07:56:17", "url": "https://files.pythonhosted.org/packages/d1/74/319a60ea4ec19196642c95e709416840f78b5599d1fced23142d1011322d/ztq_worker-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "6ed6ce9b04f12f3b1110cffa556f7dc5", "sha256": "4876c8f4b0169229195e018d0367991bb71b87d19d565182a96376f79ab00b88" }, "downloads": -1, "filename": "ztq_worker-1.2.2.tar.gz", "has_sig": false, "md5_digest": "6ed6ce9b04f12f3b1110cffa556f7dc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15979, "upload_time": "2014-03-07T06:01:09", "url": "https://files.pythonhosted.org/packages/7d/28/e76947cfff2529c818c99dd3362f13fa59d56da501ad02bdc80bd22ddcb4/ztq_worker-1.2.2.tar.gz" } ], "1.2.3": [ { "comment_text": "", "digests": { "md5": "baa6a7581d2dec7db2a0ff934882039a", "sha256": "73d647cd3a8cb741729bbb001b69807f0ae28c3f22d484191de45350e3ed5009" }, "downloads": -1, "filename": "ztq_worker-1.2.3.tar.gz", "has_sig": false, "md5_digest": "baa6a7581d2dec7db2a0ff934882039a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15985, "upload_time": "2014-03-07T06:53:10", "url": "https://files.pythonhosted.org/packages/d3/f6/9d781ee04cfc8b4052f71d34588934dfa98183318240fef746de66f6c5ef/ztq_worker-1.2.3.tar.gz" } ], "1.2.4": [ { "comment_text": "", "digests": { "md5": "e320aa7a5c56a37cbd65dc93c6133d96", "sha256": "756b76d43bcf3ab7fa70be1e99a19d452cd0f2b9808c5d21e3019c88688a4a7d" }, "downloads": -1, "filename": "ztq_worker-1.2.4.tar.gz", "has_sig": false, "md5_digest": "e320aa7a5c56a37cbd65dc93c6133d96", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15975, "upload_time": "2014-03-07T08:14:24", "url": "https://files.pythonhosted.org/packages/d3/cc/cf1a25d18224dc7a9d9b6c7c7c1c6dcddc8c89f06eb7c308a1d111ba0232/ztq_worker-1.2.4.tar.gz" } ], "1.2.5": [ { "comment_text": "", "digests": { "md5": "fbe14d7befa1cb77ab04a1c50984b43c", "sha256": "92550da7e9a2c83d417bc0516aa7afe2c1550f7ad1d6157ae9bd5ee13b523c2a" }, "downloads": -1, "filename": "ztq_worker-1.2.5.tar.gz", "has_sig": false, "md5_digest": "fbe14d7befa1cb77ab04a1c50984b43c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15999, "upload_time": "2014-03-13T10:10:09", "url": "https://files.pythonhosted.org/packages/01/5a/1553377190a00d9f84c456c0f80b7e6795847d53006a57f256cb8548e500/ztq_worker-1.2.5.tar.gz" } ], "1.2.6": [ { "comment_text": "", "digests": { "md5": "cd507aec6e3c8e6023432aaaec179b94", "sha256": "6e5c1f52de9652a174c234596401303c2909e04e3487af3b27767cc476be912f" }, "downloads": -1, "filename": "ztq_worker-1.2.6.tar.gz", "has_sig": false, "md5_digest": "cd507aec6e3c8e6023432aaaec179b94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16024, "upload_time": "2014-03-25T08:50:34", "url": "https://files.pythonhosted.org/packages/97/26/43e3864fd6bd8b0c0b952956e310d9855cb37bcb05e99614b05e09ee7118/ztq_worker-1.2.6.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "311a61c31c0a48b4a22b1ef276512e52", "sha256": "788b37e20dca51d43fb6f115db6706c19667cbc4c43a257a60f30dbd96778280" }, "downloads": -1, "filename": "ztq_worker-1.3.0.tar.gz", "has_sig": false, "md5_digest": "311a61c31c0a48b4a22b1ef276512e52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16223, "upload_time": "2014-09-22T07:01:29", "url": "https://files.pythonhosted.org/packages/2a/13/84dfcdb27dd9aa82718833377ff8bcecd0970c8674a2a7ef86646d2198f1/ztq_worker-1.3.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "bf6e34d70a1c4b8f404391185ab108c4", "sha256": "d22e3781e8f3efa6a22ae415a39999fbf2e43b85911fba7ff0d07097a4e7ffd5" }, "downloads": -1, "filename": "ztq_worker-1.3.1.tar.gz", "has_sig": false, "md5_digest": "bf6e34d70a1c4b8f404391185ab108c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16263, "upload_time": "2015-05-19T02:44:58", "url": "https://files.pythonhosted.org/packages/a3/ab/b9007071649b7f34c05395021a0d09c65e9b44028fe987e333e9978574ad/ztq_worker-1.3.1.tar.gz" } ], "1.3.2": [ { "comment_text": "", "digests": { "md5": "edd6d3927b8d055557873f2131561e49", "sha256": "9366f5c65c7d9b1885f9be761e9c3f28e5cfdd8ce7ca5f0c913b2555bb1f2886" }, "downloads": -1, "filename": "ztq_worker-1.3.2.tar.gz", "has_sig": false, "md5_digest": "edd6d3927b8d055557873f2131561e49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16263, "upload_time": "2015-05-19T03:27:37", "url": "https://files.pythonhosted.org/packages/4c/d2/51fa4a46016886ba151d9fbcd02cc8548255703f990ed489521ca57002b0/ztq_worker-1.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "edd6d3927b8d055557873f2131561e49", "sha256": "9366f5c65c7d9b1885f9be761e9c3f28e5cfdd8ce7ca5f0c913b2555bb1f2886" }, "downloads": -1, "filename": "ztq_worker-1.3.2.tar.gz", "has_sig": false, "md5_digest": "edd6d3927b8d055557873f2131561e49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16263, "upload_time": "2015-05-19T03:27:37", "url": "https://files.pythonhosted.org/packages/4c/d2/51fa4a46016886ba151d9fbcd02cc8548255703f990ed489521ca57002b0/ztq_worker-1.3.2.tar.gz" } ] }