{ "info": { "author": "Massimo DiPierro", "author_email": "massimo.dipierro@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# tasktuils\n\n**taskutils** is a implements a multithreaded scheduler in Python. \nIt provide methods to enqueue tasks and set simple policies, for example:\n\n- execute once with this priority\n- execute every 10 minutes\n- retry twice if it fails\n- execute no more than 3 tasks concurrently\n\nIt can used to power more complex programs that need concurrency, for example a crawler.\n\nHere is an example of usage:\n\n### Install it\n\n pip install taskutils\n\n### Import the relevant objects\n\n from taskutils import TaskHandler, Task, Recurrent\n\n### Create the main task handler object\n\n task_handler = TaskHandler(max_num_threads=3, sleep_seconds=2)\n\nThis will create 3 threads that wait for tasks to be queued every 2 seconds.\n\n### Queue some simple tasks\n\n def foo(k): print 'hello world from task %s' % k\n\n for k in range(10):\n task = Task(foo, kwargs=dict(k=k), priority=k, repeats_on_failure=3)\n task_handler.enqueue_task(task)\n\nThis will enqueue 10 tasks (with arbitrary parameter k=0...9) which will be executed by\nthe task handler threads when free. If a task fails it will be retried 3 times before being \ndiscarded. Notice that a task contain a function (in this case foo) and its arguments.\n\n### Queue a recurrent task\n\n task = Task(foo, kwargs=dict(k=10), repeats_on_failure=0)\n task_handler.recurrent_tasks['abc'] = Recurrent(task, interval=3, repeats=5)\n\nRecurrent tasks are wrapped into the Recurrent() object and must be named (for example 'abc').\nRecurrent tasks are named because they are not placed in the normal queue but are executed always \nwith max priority when their time comes. In the above example the 'abc' task is executed \n5 times every 3 seconds. A recurrent task can be removed via\n\n del task_handler.recurrent_tasks['abc']\n\n### Other goodies\n\n from taskutils import LockWrapper\n with_a_lock = LockWrapper()\n\nIt defines a decorator that makes sure all code called with the decorator is always serialized, even if called in different Tasks:\n\n @with_a_lock\n def f(): print 'a'\n \n @with_a_lock\n def g(): print 'b'\n\n task_handler.enqueue_task(Task(f))\n task_handler.enqueue_task(Task(g))\n\nThis makes sure that the excution of functions f and g is never concurrent.\n\n## License\n\nCreated by Massimo Di Pierro (http://experts4solutions.com) @2016 BSDv3 License", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mdipierro/taskutils", "keywords": "task scheduler", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "taskutils", "package_url": "https://pypi.org/project/taskutils/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/taskutils/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/mdipierro/taskutils" }, "release_url": "https://pypi.org/project/taskutils/0.2/", "requires_dist": null, "requires_python": null, "summary": "A multithreaded task scheduler for task queues and recurrent tasks", "version": "0.2" }, "last_serial": 1950079, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "6ea20c2f5de69ce760f187b07209ddaf", "sha256": "4b64da91c4f6bfeca2a8d43256f017ccd311dec836e938feda44c1103047767c" }, "downloads": -1, "filename": "taskutils-0.1.tar.gz", "has_sig": false, "md5_digest": "6ea20c2f5de69ce760f187b07209ddaf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3835, "upload_time": "2016-01-27T04:52:14", "url": "https://files.pythonhosted.org/packages/da/8e/05fef66a182a694a48b788ea01cc2e1b3c149fa7d968a42d62c30461152b/taskutils-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ab5623c8cf97fea62b2c4fdf6f242eb0", "sha256": "82e39b64b1d4ddf9117c616dc0f2e8597c57f7a5684541758d198866cc654156" }, "downloads": -1, "filename": "taskutils-0.2.tar.gz", "has_sig": false, "md5_digest": "ab5623c8cf97fea62b2c4fdf6f242eb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3873, "upload_time": "2016-02-10T21:50:38", "url": "https://files.pythonhosted.org/packages/9e/72/1855e806cc850d8866e7b69cbb682a0983342f1d041df07136c8ef37f35e/taskutils-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ab5623c8cf97fea62b2c4fdf6f242eb0", "sha256": "82e39b64b1d4ddf9117c616dc0f2e8597c57f7a5684541758d198866cc654156" }, "downloads": -1, "filename": "taskutils-0.2.tar.gz", "has_sig": false, "md5_digest": "ab5623c8cf97fea62b2c4fdf6f242eb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3873, "upload_time": "2016-02-10T21:50:38", "url": "https://files.pythonhosted.org/packages/9e/72/1855e806cc850d8866e7b69cbb682a0983342f1d041df07136c8ef37f35e/taskutils-0.2.tar.gz" } ] }