{ "info": { "author": "Thierry Spetebroot ", "author_email": "thierry.spetebroot@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: AsyncIO", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "# aio-timers\n\n[![PyPI - License](https://img.shields.io/pypi/l/aio-times.svg?longCache=true&&style=flat-square)](https://github.com/ThierrySpetebroot/aio-timers/blob/master/LICENSE)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aio-times.svg?longCache=true&&style=flat-square)\n[![PyPI](https://img.shields.io/pypi/v/aio-times.svg?longCache=true&&style=flat-square)](https://test.pypi.org/project/aio-timers/)\n\n\nTiming utilities based on `asyncio`.\n\n## Setup\n`pip install aio-timers`\n\n## Usage\n```python\nimport asyncio\nfrom aio_timers import Timer\n\ndef callback(name):\n print(\"Hello {}!\".format(name))\n\n# timer is scheduled here\ntimer = Timer(5, callback, callback_args=(\"World\",))\n\n# wait until the callback has been executed\nloop = asyncio.get_event_loop()\nloop.run_until_complete(timer.wait())\nprint(\"end\")\n```\n\nOutput:\n\n(after 5 seconds)\n> Hello World!\n>\n> end\n\n### Timer\n\nCalls a `callback` after `delay` seconds.\n\nThe timer is executed as a task on an event loop.\n\nThe callback is invoked:\n - as a synchronous function if it is not a coroutine;\n - with an await if it is a coroutine or the `callback_async` flag is set to `True`.\n\nAny result returned by the callback is ignored.\n\n#### Constructor\n`Timer(delay, callback, callback_args=(), callback_kwargs={}, callback_async=False, *, loop=None)`\n\nwhere:\n - delay, seconds before the `callback` is executed;\n - callback, the callback to execute after `delay` seconds\n - callback_args, (optional, default=`()`) positional arguments to pass to `callback`\n - callback_kwargs, (optional, default=`{}`) keyword arguments to pass to `callback`\n - callback_async, (optional, default=`False`) if `True` the callback will be executed on the event loop (`await`)\n - loop, (optional, default=`None`) event loop where the delayed task will be scheduled (if`None` will use `asyncio.get_event_loop()`)\n\nNOTE: the `callback_async` flag should be used when a coroutine is decorated (e.g., using `functools.partial`)\n\n#### .cancel()\nCancels the execution of the callback.\n\n#### async .wait()\nWait until the callback has been executed or its execution has been canceled.\n\nIf the execution has been canceled, will raise `asyncio.CancelledError`.", "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/ThierrySpetebroot/aio-timers", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "aio-timers", "package_url": "https://pypi.org/project/aio-timers/", "platform": "all", "project_url": "https://pypi.org/project/aio-timers/", "project_urls": { "Homepage": "https://github.com/ThierrySpetebroot/aio-timers" }, "release_url": "https://pypi.org/project/aio-timers/0.0.1/", "requires_dist": null, "requires_python": ">=3.5.*, <4", "summary": "Timer support for asyncio.", "version": "0.0.1" }, "last_serial": 4097740, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d1febbd2550cd917ea8a2d4d38303e23", "sha256": "56a51137f374d8cdcead20d0a139acc8ed29ca500434b26915cbd8bd76f680fc" }, "downloads": -1, "filename": "aio-timers-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d1febbd2550cd917ea8a2d4d38303e23", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.*, <4", "size": 3299, "upload_time": "2018-07-24T17:15:42", "url": "https://files.pythonhosted.org/packages/e7/79/ed582e969701c57ca2010570d0e5f7cd9521b5be98befa4c4a97c958d574/aio-timers-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d1febbd2550cd917ea8a2d4d38303e23", "sha256": "56a51137f374d8cdcead20d0a139acc8ed29ca500434b26915cbd8bd76f680fc" }, "downloads": -1, "filename": "aio-timers-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d1febbd2550cd917ea8a2d4d38303e23", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.*, <4", "size": 3299, "upload_time": "2018-07-24T17:15:42", "url": "https://files.pythonhosted.org/packages/e7/79/ed582e969701c57ca2010570d0e5f7cd9521b5be98befa4c4a97c958d574/aio-timers-0.0.1.tar.gz" } ] }