{ "info": { "author": "edo", "author_email": "service@everydo.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Pyramid", "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": "http://everydo.com/", "keywords": "Everydo queue monitor console async", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "ztq_console", "package_url": "https://pypi.org/project/ztq_console/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ztq_console/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://everydo.com/" }, "release_url": "https://pypi.org/project/ztq_console/1.2.5/", "requires_dist": null, "requires_python": null, "summary": "Zopen Task Queue Console", "version": "1.2.5" }, "last_serial": 1472883, "releases": { "1.0dev": [ { "comment_text": "", "digests": { "md5": "55705e4462096793ee0e02d63d9515f9", "sha256": "61da58120b69939494a83c02673bf9d949ac098605bc59826c8af08ef591d206" }, "downloads": -1, "filename": "ztq_console-1.0dev.tar.gz", "has_sig": false, "md5_digest": "55705e4462096793ee0e02d63d9515f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 61552, "upload_time": "2012-10-22T03:55:00", "url": "https://files.pythonhosted.org/packages/cb/52/4c6b924020275b525e698b0d1f0cdf93acf28f67bc6042199a369ae39bae/ztq_console-1.0dev.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "acbc3206d80b5ae7c79dd0bb28a9ac47", "sha256": "117e4f08f20e2b59ba38829cf2712a509546cdbdb373af987c6a5d610af36b9a" }, "downloads": -1, "filename": "ztq_console-1.1.tar.gz", "has_sig": false, "md5_digest": "acbc3206d80b5ae7c79dd0bb28a9ac47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 97276, "upload_time": "2014-01-16T01:47:34", "url": "https://files.pythonhosted.org/packages/51/67/328408b8875f007fad5e1ad45c5ce05e070f27b2c638e3e652b11298f5ef/ztq_console-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "c9f5940f210e3c05a65869aee34e8299", "sha256": "28acbae3be268928f718cb9c3c0f542a4830e2eb84139162b7df314e7959e403" }, "downloads": -1, "filename": "ztq_console-1.2.tar.gz", "has_sig": false, "md5_digest": "c9f5940f210e3c05a65869aee34e8299", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 102153, "upload_time": "2014-01-16T05:57:00", "url": "https://files.pythonhosted.org/packages/73/8b/b5680547b24c7eb0ec1f7415733f1017264138bf1956c70065fbd89692d6/ztq_console-1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "757475f1afca658f40eabd18eaf585d4", "sha256": "53aba3fcbeb304c038623ff1b074084ee0f27fcc83eed5872781c672f90282a7" }, "downloads": -1, "filename": "ztq_console-1.2.1.tar.gz", "has_sig": false, "md5_digest": "757475f1afca658f40eabd18eaf585d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 102681, "upload_time": "2014-01-17T15:33:16", "url": "https://files.pythonhosted.org/packages/a4/08/3ec4316d621a74a9e2d852009eaefe2768343c9b7baf13b6b3ec34353da2/ztq_console-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "3eda182ace6d741950a96278878258af", "sha256": "fbde475d0441e9c2aabaa4c3bbe6dc469ae0bd86111999ce70c01a9e805c595e" }, "downloads": -1, "filename": "ztq_console-1.2.2.tar.gz", "has_sig": false, "md5_digest": "3eda182ace6d741950a96278878258af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 102755, "upload_time": "2014-02-14T03:22:29", "url": "https://files.pythonhosted.org/packages/64/7f/3b8b3201e241426ac9928da3f3c668232e5c4c2df281a6df16db75354722/ztq_console-1.2.2.tar.gz" } ], "1.2.4": [ { "comment_text": "", "digests": { "md5": "d25eea818f8b108e43bc3d68f80c36b2", "sha256": "3c7f146bbc179c278f9e763a2a9c86609cdb08ac030ec10bbc568e4111cd7a25" }, "downloads": -1, "filename": "ztq_console-1.2.4.tar.gz", "has_sig": false, "md5_digest": "d25eea818f8b108e43bc3d68f80c36b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 101568, "upload_time": "2014-09-22T07:18:22", "url": "https://files.pythonhosted.org/packages/18/62/d708329922ca000bd93efce510404dcb827b965865046df497db5aa1bbab/ztq_console-1.2.4.tar.gz" } ], "1.2.5": [ { "comment_text": "", "digests": { "md5": "34025937f0edf5703baffbbb7539c171", "sha256": "1277ead8be408910ed2308b14f05084203f03d906f17c80e5019743ea9d9c595" }, "downloads": -1, "filename": "ztq_console-1.2.5.tar.gz", "has_sig": false, "md5_digest": "34025937f0edf5703baffbbb7539c171", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 101565, "upload_time": "2015-03-23T06:39:00", "url": "https://files.pythonhosted.org/packages/a4/55/ca5c53f4dd108c83e9f65d84c8bf808f3e392a1a55a8b75c7c087ad700cc/ztq_console-1.2.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "34025937f0edf5703baffbbb7539c171", "sha256": "1277ead8be408910ed2308b14f05084203f03d906f17c80e5019743ea9d9c595" }, "downloads": -1, "filename": "ztq_console-1.2.5.tar.gz", "has_sig": false, "md5_digest": "34025937f0edf5703baffbbb7539c171", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 101565, "upload_time": "2015-03-23T06:39:00", "url": "https://files.pythonhosted.org/packages/a4/55/ca5c53f4dd108c83e9f65d84c8bf808f3e392a1a55a8b75c7c087ad700cc/ztq_console-1.2.5.tar.gz" } ] }