{ "info": { "author": "Blake VandeMerwe", "author_email": "blakev@null.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries" ], "description": "# gevent-tasks\n\n[![pypi](https://img.shields.io/pypi/v/gevent-tasks.svg?style=flat)](https://pypi.python.org/pypi/gevent-tasks)\n[![docs](https://readthedocs.org/projects/gevent-tasks/badge/?version=latest)](http://gevent-tasks.readthedocs.io/en/latest/)\n[![MIT License](https://img.shields.io/github/license/blakev/gevent-tasks.svg?style=flat)](https://github.com/blakev/gevent-tasks/blob/master/LICENSE)\n\n\nBackground task manager using Gevent and Green threads.\n\n- Check out [the documentation](http://gevent-tasks.readthedocs.io/en/latest/).\n- Learn about [Gevent]().\n\nThis library is designed to allow a developer to run arbitrary \"tasks\" as background\nthreads on a fixed/normalized interval. Each task is a wrapped\ncallable that takes at least one parameter `task`, a reference to itself. Timings\nand related metadata can be accessed via the `task` value as well as the ability\nto stop and reschedule itself for future events.\n\n\n`TaskManager` has a `TaskPool` that runs `Tasks`.\n\n## Installation\n\nThe latest version from pypi,\n\n```bash\n$ pip install gevent-tasks\n```\n\nThe latest development version from source,\n\n```bash\n$ pip install git+git@github.com:blakev/gevent-tasks.git@develop\n```\n\n\n\n## Examples\n\nA classic example,\n\n```python\n# print our system uptime every minute, indefinitely\n\nfrom datetime import timedelta\nfrom gevent_tasks import TaskManager, cron\n\nmanage = TaskManager()\n\n@manage.task(interval=cron('* * * * *'))\ndef system_uptime(task):\n with open('/proc/uptime', 'r') as f:\n uptime_seconds = float(f.readline().split()[0])\n uptime = str(timedelta(seconds=uptime_seconds))\n print(uptime)\n\nmanage.forever(stop_after_exc=False)\n```\n\nContrived example,\n\n```python\nfrom gevent.monkey import patch_all\npatch_all()\n\nfrom gevent_tasks import Task, TaskManager, TaskPool\n\nfrom myapp.tasks import check_websockets, check_uptime, check_health\n\npool = TaskPool(size=25)\nmanager = TaskManager(pool=pool)\n\nmanager.add_many(\n Task('WebsocketHealth', check_websockets, interval=7.5),\n Task('ApplicationHealth', check_uptime, interval=30.0),\n Task('SystemHealth', check_health, args=('localhost',), interval=2.5)\n)\nmanager.start_all()\n..\n..\nhttp_server.serve_forever()\n```\n\nUsing the [`parse-crontab`](https://github.com/josiahcarlson/parse-crontab)\n module we're able to define intervals with cron syntax,\n\n```python\nfrom gevent_tasks import Task, cron\n..\n..\nTask('ShowCharts', show_charts, interval=cron('* * * * *'), timeout=30.0)\n```\n\nThe manager instance can also be used to register tasks via decorator. Calling \n`TaskManager.forever()` will block the code until there are no longer scheduled tasks or until an `Exception` \nis thrown inside one of the running Tasks.\n\n```python\nmanage = TaskManager()\n\n@manage.task(interval=cron('* * * * *'))\ndef every_minute(task, *args):\n print('hi', args, task, task.timing)\n\nmanage.forever()\n```\n\nYou can also reference the previous return value, allowing tasks to build on\nthemselves over time without human / programmatic interaction.\n\n```python\n@manage.task(interval=1)\ndef random_number(task):\n num = random.randint(0, 100)\n print(task.value, num)\n return num\n\n.. output ..\n\nNone 51\n51 50\n50 88\n88 26\n```\n\n### Attribution\n\nThis module relies primarily on the [`gevent`](http://www.gevent.org/index.html) \nproject for all its core functionality.\n\n### MIT License\n\nCopyright (c) 2017 Blake VandeMerwe\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/blakev/gevent-tasks", "keywords": "gevent,background,bg,tasks,worker,threading,thread", "license": "MIT", "maintainer": "Blake VandeMerwe", "maintainer_email": "blakev@null.net", "name": "gevent-tasks", "package_url": "https://pypi.org/project/gevent-tasks/", "platform": "", "project_url": "https://pypi.org/project/gevent-tasks/", "project_urls": { "Documentation": "http://gevent-tasks.readthedocs.io/en/latest/", "Homepage": "https://github.com/blakev/gevent-tasks" }, "release_url": "https://pypi.org/project/gevent-tasks/0.3.1/", "requires_dist": [ "crontab (>=0.22.4,<0.23.0)", "gevent (>=1.4.0,<2.0.0)" ], "requires_python": ">=3.6,<4.0", "summary": "Background task management using gevent and green threads.", "version": "0.3.1" }, "last_serial": 4775536, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "1fda30435dc5b3b04ded4c60a11197c6", "sha256": "9c6d2fb13a2cea0bf6f5222a6055c5239fd9a69cfd9793e655c6dc7ea8b7b5d7" }, "downloads": -1, "filename": "gevent-tasks-0.1.0.tar.gz", "has_sig": false, "md5_digest": "1fda30435dc5b3b04ded4c60a11197c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4574, "upload_time": "2017-10-18T20:00:02", "url": "https://files.pythonhosted.org/packages/5d/3a/1f73854e80a029961d934ef46bda8655852d18636ef8c32b4cb41793dd33/gevent-tasks-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "c4480e3df6df5ed1f19922de9e2e28a0", "sha256": "9f11fe507de610b5b16d1c95990571f7910549d19a92e77d091cd8c31559d333" }, "downloads": -1, "filename": "gevent-tasks-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c4480e3df6df5ed1f19922de9e2e28a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5596, "upload_time": "2017-10-18T20:20:39", "url": "https://files.pythonhosted.org/packages/bc/b7/f33955f708a9b38b6e67d490965bdfc2b7a8f8c577eb2e042c0cefd65b8b/gevent-tasks-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6783fb2f931772d58befc95fd59851d3", "sha256": "4887622354ba6b956d56777839c1515dab2f3319014b9ac3664692f1779c75c5" }, "downloads": -1, "filename": "gevent-tasks-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6783fb2f931772d58befc95fd59851d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6063, "upload_time": "2017-10-18T20:52:18", "url": "https://files.pythonhosted.org/packages/b2/61/0010692a2961723fe284f0cce5b817f2ba03ea221cd9906cb53e58e4a387/gevent-tasks-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "efc6c5e03379cdfb3b52547293be5cfb", "sha256": "8f05ad5588898184cfc4edc042b27b2347296058099e7e32db0f874e7338b819" }, "downloads": -1, "filename": "gevent-tasks-0.1.3.tar.gz", "has_sig": false, "md5_digest": "efc6c5e03379cdfb3b52547293be5cfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7010, "upload_time": "2017-10-18T22:47:07", "url": "https://files.pythonhosted.org/packages/e6/f6/6e8f7b87c49873a444efd560304bdd101872de7eb026295c141cd62f1b37/gevent-tasks-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "704e81b3ae65671e458ed1cee1830934", "sha256": "87d4c03bcdf252ffff293e7bef4e1d9c3e62335b5c85c22961d29b5124656577" }, "downloads": -1, "filename": "gevent-tasks-0.1.4.tar.gz", "has_sig": false, "md5_digest": "704e81b3ae65671e458ed1cee1830934", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7622, "upload_time": "2017-10-19T20:35:18", "url": "https://files.pythonhosted.org/packages/8b/eb/be635de2191236850759d565c7c448cd373a3b406cd2989b5e432f0126c8/gevent-tasks-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "4c2bb35c3be3fac9bf25c4075c54bfaa", "sha256": "95b216741fada97ef9932c1ce4fc173a258a2337ae44cc2e1547bc28dea52ef5" }, "downloads": -1, "filename": "gevent-tasks-0.1.5.tar.gz", "has_sig": false, "md5_digest": "4c2bb35c3be3fac9bf25c4075c54bfaa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8937, "upload_time": "2017-10-19T21:38:05", "url": "https://files.pythonhosted.org/packages/a2/9c/2125a1564d7682d5be82885834393e2f2f07c6fdefc7cdf06181dccca8cf/gevent-tasks-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "b559b19ba224049ab0d5227a4040012c", "sha256": "b803df78cd0b3e762afd933b6402cfacea1f34d3c171467760af62e3e504b7f8" }, "downloads": -1, "filename": "gevent-tasks-0.1.6.tar.gz", "has_sig": false, "md5_digest": "b559b19ba224049ab0d5227a4040012c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10883, "upload_time": "2017-10-23T20:13:20", "url": "https://files.pythonhosted.org/packages/fa/14/ebc85cd1e30e0bd1bfbe155761148fb342280c4114414844275510ef4274/gevent-tasks-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "37791deedf592063225cd95f7e7f24e9", "sha256": "c39a3348716d02ecf0e3a23aced7dd97e43616c3b40dd6d53efc4575bcee115a" }, "downloads": -1, "filename": "gevent-tasks-0.1.7.tar.gz", "has_sig": false, "md5_digest": "37791deedf592063225cd95f7e7f24e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11126, "upload_time": "2017-10-23T20:40:14", "url": "https://files.pythonhosted.org/packages/02/1e/4fb9ab40378dd9daedfe9ed31ce3455383d8837691586b80d5fd650be765/gevent-tasks-0.1.7.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1408586154e6e558ce08fbbd2694250b", "sha256": "e0ede09313871a324bb7be953b74649436a399bbbe274a62ae168b45aac9d492" }, "downloads": -1, "filename": "gevent-tasks-0.2.0.tar.gz", "has_sig": false, "md5_digest": "1408586154e6e558ce08fbbd2694250b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 14265, "upload_time": "2019-02-01T23:25:21", "url": "https://files.pythonhosted.org/packages/9b/55/0f9634469851b5f0fb2101cc70be380dd57404fe28509b87aa3345ab3d1f/gevent-tasks-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "f5554705dc10e990fbbcfb4343f00c72", "sha256": "843e8428c103af0fb97392b6c509c74b0e092e08cc412c86116bbea368c55e68" }, "downloads": -1, "filename": "gevent-tasks-0.3.0.tar.gz", "has_sig": false, "md5_digest": "f5554705dc10e990fbbcfb4343f00c72", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 14217, "upload_time": "2019-02-01T23:33:50", "url": "https://files.pythonhosted.org/packages/42/cf/8d6e250463f680867786953735ea941ed574f7afb6f1e9785eec5a2c4490/gevent-tasks-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "2de844b8e640390c9c579bec08c7ce16", "sha256": "01af4bc8280f19e8da27f2ffd1948f1c813bf6988d2ed7d60061775a0c5187c1" }, "downloads": -1, "filename": "gevent-tasks-0.3.1.tar.gz", "has_sig": false, "md5_digest": "2de844b8e640390c9c579bec08c7ce16", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 14787, "upload_time": "2019-02-03T20:12:26", "url": "https://files.pythonhosted.org/packages/da/3d/0c9e0ed1dca4369be028b3f81d3346aeddfc300880aeb5afe7ca3d1bf1d0/gevent-tasks-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2de844b8e640390c9c579bec08c7ce16", "sha256": "01af4bc8280f19e8da27f2ffd1948f1c813bf6988d2ed7d60061775a0c5187c1" }, "downloads": -1, "filename": "gevent-tasks-0.3.1.tar.gz", "has_sig": false, "md5_digest": "2de844b8e640390c9c579bec08c7ce16", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 14787, "upload_time": "2019-02-03T20:12:26", "url": "https://files.pythonhosted.org/packages/da/3d/0c9e0ed1dca4369be028b3f81d3346aeddfc300880aeb5afe7ca3d1bf1d0/gevent-tasks-0.3.1.tar.gz" } ] }