{ "info": { "author": "Tobias Gawron-Deutsch", "author_email": "tobias@strix.at", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Environment :: No Input/Output (Daemon)", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3" ], "description": "Simple Asynchronous Scheduler\n=============================\n\nAsyncScheduler is a wrapper for sched.scheduler that provides\nasynchronous operation out of the box. Thus, starting the scheduler does\nnot block the execution of the next statements. Further, adding and\nremoving events can be done without manually stopping/starting the\nscheduler.\n\nThe event itself is executed synchronously. Consequently, it the\nexecution of the calling method takes longer than the delay to the next\nevent, execution of the next method is postponed until the previous\nmethod returns.\n\nFour different methods are available to add new events: \\* ``enter`` -\nadds a single event to take place in n seconds \\* ``enterabs`` - adds a\nsingle event to take place at time t \\* ``repeat`` - adds a repeating\nevent that is triggered every n seconds \\* ``enterabs`` - adds a\nrepeating event that is triggered at time t for the first time and then\nevery n seconds\n\nExample\n=======\n\nSome events\n-----------\n\nCode\n~~~~\n\n::\n\n from asyncscheduler import AsyncScheduler\n from time import sleep\n\n a = AsyncScheduler()\n a.start()\n event = a.enter(1, 1, print, args=(\"event 1\",))\n a.enter(2, 1, print, args=(\"event 2\",))\n a.enter(3, 1, print, args=(\"event 3\",))\n a.enter(4, 1, print, args=(\"event 4\",))\n a.cancel(event)\n sleep(3.1)\n a.clear_scheduler()\n a.stop()\n\nOutput\n~~~~~~\n\n::\n\n event 2\n event 3\n\nDigital clock\n-------------\n\nCode\n~~~~\n\n::\n\n from asyncscheduler import AsyncScheduler\n import time, datetime\n\n\n def display_time():\n print(\"\\r{}\".format(datetime.datetime.now().strftime(\"%H:%M:%S\")), end='\\r')\n\n\n a = AsyncScheduler()\n a.start()\n a.repeatabs(math.floor(time.time()) + 1, 1, 1, display_time)\n\n try:\n while True:\n time.sleep(0.25)\n except KeyboardInterrupt:\n pass\n\n a.stop()\n\nOutput\n~~~~~~\n\n::\n\n 12:34:56\n\nAPI\n===\n\nenter\n-----\n\n``AsyncScheduler.enter(self, delay, priority, action, args=(), kwargs={})``\n\nAdd an event to the scheduler. It will be executed after the provided\ndelay with 'action(\\*argument, \\*\\*kwargs)'. In case of two events\nscheduled for the same time the priority is used for execution order. A\nlower number means a higher priority.\n\nParameter: \\* ``delay`` - delay call of func for this amount of seconds.\ne.g. 12.34 \\* ``priority`` - events scheduled for the same time are\nprocessed according to their priority. \\* ``action`` - function that is\ncalled upon expires \\* ``args`` - tuple of arguments for this function\n\\* ``kwargs`` - dict of arguments for this function\n\nReturns the instance of the added event.\n\nenterabs\n--------\n\n``AsyncScheduler.enterabs(self, time, priority, action, args=(), kwargs={})``\n\nAdd an event to the scheduler. It will be executed at the provided time\nwith 'action(\\*argument, \\*\\*kwargs)'. In case of two events scheduled\nfor the same time the priority is used for execution order. A lower\nnumber means a higher priority.\n\nParameter: \\* ``time`` - call the action at this time stamp. \\*\n``priority`` - events scheduled for the same time are processed\naccording to their priority. \\* ``action`` - function that is called\nupon expires \\* ``args`` - tuple of arguments for this function \\*\n``kwargs`` - dict of arguments for this function\n\nReturns the instance of the added event.\n\nclear\\_scheduler\n----------------\n\n``AsyncScheduler.clear_scheduler(self)``\n\nCancels all scheduled events.\n\ncancel\n------\n\n``AsyncScheduler.cancel(self, event)``\n\nRemove the provided event from the scheduler. In case of an unknown\nevent, a ValueError will be raised.\n\nParameter: \\* ``event`` - event instance as returned from add\\_event.\n\nrepeat\n------\n\n``repeat(self, every, priority, action, args=(), kwargs={})``\n\nAdd a repeating event to the scheduler. It will be executed each time\nthe provided delay (every-n-seconds) has expired with 'func(\\*argument,\n\\*\\*kwargs)'. In case of two events scheduled for the same time the\npriority is used for execution order. A lower number means a higher\npriority.\n\nSee repeatabs for more information.\n\nParameter: \\* ``time`` - call the action at this time stamp. \\*\n``every`` - every-n-seconds call action. e.g. 12.34 \\* ``priority`` -\nevents scheduled for the same time are processed according to their\npriority. \\* ``action`` - function that is called upon expirey \\*\n``args`` - tuple of arguments for this function \\* ``kwargs`` - dict of\narguments for this function\n\nReturns the instance of the added event.\n\nrepeatabs\n---------\n\n``repeatabs(self, time, every, priority, action, args=(), kwargs={})``\n\nAdd a repeating event to the scheduler. It will be executed each time\nthe provided delay (every-n-seconds) has expired with 'func(\\*argument,\n\\*\\*kwargs)'. The first event is triggered at the provided time. In case\nof two events scheduled for the same time the priority is used for\nexecution order. A lower number means a higher priority.\n\nA repeating event will trigger one last time in case of a regular stop\nwith wait=False (=default).\n\nNote: the returned event instance is the instance of the first iteration\nonly. Thus, after the first iteration it will not be part of\nscheduler.queue no more. Instead a new event for this repeating event\nhas been created. AsyncScheduler keeps track of the current instance and\nuses the first instance for identification of which event to cancel.\nThis is done with the method \\_repeat\\_event\\_hash and the map\n\\_repeat\\_event\\_mapping.\n\nParameter: \\* ``time`` - call the action at this time stamp. \\*\n``every`` - every-n-seconds call action. e.g. 12.34 \\* ``priority`` -\nevents scheduled for the same time are processed according to their\npriority. \\* ``action`` - function that is called upon expirey \\*\n``args`` - tuple of arguments for this function \\* ``kwargs`` - dict of\narguments for this function\n\nReturns the instance of the added event.\n\nstart\n-----\n\n``start(self)``\n\nStarts the scheduler.\n\nstop\n----\n\n``stop(self)``\n\nStops the scheduler. After stop, the scheduler is emptied. Thus, calling\n``start`` after ``stop`` results in a new, blank schedule that must be\nfilled.\n\nTodos\n=====\n\n- readthedocs\n- CI/CD\n\nMisc\n====\n\nThe code is written for ``python3`` (and tested with python 3.5).\n\n`Merge\nrequests `__\n/ `bug\nreports `__\nare always welcome.\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/tgd1975/simple_asynchronous_scheduler/", "keywords": "sched scheduler", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "AsyncScheduler", "package_url": "https://pypi.org/project/AsyncScheduler/", "platform": "", "project_url": "https://pypi.org/project/AsyncScheduler/", "project_urls": { "Homepage": "https://gitlab.com/tgd1975/simple_asynchronous_scheduler/" }, "release_url": "https://pypi.org/project/AsyncScheduler/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "A simpler asynchronous scheduler based on pythons sched.scheduler.", "version": "0.2.0" }, "last_serial": 4976881, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "ab1345394c846907b9897a19148f4726", "sha256": "a51dc99eb2339bd6bed70eee239fcab75b0f2dde71114d77a73e51d92456b428" }, "downloads": -1, "filename": "AsyncScheduler-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ab1345394c846907b9897a19148f4726", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4755, "upload_time": "2019-03-21T20:31:40", "url": "https://files.pythonhosted.org/packages/8d/e6/4b8085e3d8e08aa6be5880c3676a76cdfd021e153ae2464529f30f176f12/AsyncScheduler-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "0c54ce2bcd4742778c2146e23c775638", "sha256": "d077131667bbcb499d13f906b2cd3670e2c359344a63a949eb1ba69263a25d00" }, "downloads": -1, "filename": "AsyncScheduler-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0c54ce2bcd4742778c2146e23c775638", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7066, "upload_time": "2019-03-23T22:47:55", "url": "https://files.pythonhosted.org/packages/c8/34/2c72a02768183a17c40376c96dffee1cc82cf0ad2118f8e5853830cf7494/AsyncScheduler-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0c54ce2bcd4742778c2146e23c775638", "sha256": "d077131667bbcb499d13f906b2cd3670e2c359344a63a949eb1ba69263a25d00" }, "downloads": -1, "filename": "AsyncScheduler-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0c54ce2bcd4742778c2146e23c775638", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7066, "upload_time": "2019-03-23T22:47:55", "url": "https://files.pythonhosted.org/packages/c8/34/2c72a02768183a17c40376c96dffee1cc82cf0ad2118f8e5853830cf7494/AsyncScheduler-0.2.0.tar.gz" } ] }