{ "info": { "author": "Michal Charemza", "author_email": "michal@charemza.name", "bugtrack_url": null, "classifiers": [ "Framework :: AsyncIO", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# aiotimeout [![CircleCI](https://circleci.com/gh/michalc/aiotimeout.svg?style=svg)](https://circleci.com/gh/michalc/aiotimeout) [![Test Coverage](https://api.codeclimate.com/v1/badges/8de540239bd7d6566f58/test_coverage)](https://codeclimate.com/github/michalc/aiotimeout/test_coverage)\n\nTimeout context manager for asyncio Python\n\n\n## Usage\n\n```python\nfrom aiotimeout import timeout\n\n# Will raise an asyncio.TimeoutError\nwith timeout(1):\n await asyncio.sleep(1.5)\n\n# Will not raise anything\nwith timeout(1):\n await asyncio.sleep(0.5)\n```\n\nYou can respond to a timeout from _outside_ the context by catching `asyncio.TimeoutError`\n\n```python\ntry:\n with timeout(1):\n await asyncio.sleep(1.5)\n print('This line is not reached')\nexcept asyncio.TimeoutError:\n print('Timed out')\n```\n\nor you can respond to a timeout from _inside_ the context by catching `asyncio.CancelledError` and re-raising.\n\n```python\ntry:\n with timeout(1):\n try:\n await asyncio.sleep(1.5)\n except asyncio.CancelledError\n print('Doing some cleanup')\n raise\nexcept asyncio.TimeoutError:\n print('Timed out')\n```\n\n\n## Differences to alternatives\n\n- `asyncio.wait_for` does not offer a context manager. In some cases a context manager is clearer.\n\n- `asyncio.wait_for` creates/uses an extra task. In some cases this is not necessary, and an extra task adds non-determinism in terms of sequence of operations.\n\n- Clearer internal code [in the author's opinion]. Rather than a custom class, [contextlib.contextmanager](https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager) is used.\n\n\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/michalc/aiotimeout", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "aiotimeout", "package_url": "https://pypi.org/project/aiotimeout/", "platform": "", "project_url": "https://pypi.org/project/aiotimeout/", "project_urls": { "Homepage": "https://github.com/michalc/aiotimeout" }, "release_url": "https://pypi.org/project/aiotimeout/0.0.4/", "requires_dist": null, "requires_python": "~=3.5", "summary": "Timeout context manager for asyncio Python", "version": "0.0.4" }, "last_serial": 5006570, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "ffd787600415eb207d9ae21d90445ca1", "sha256": "af04339e2887c326df85d00ba5316b06a64561c2fbb5a721b31c318dea42b7a6" }, "downloads": -1, "filename": "aiotimeout-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ffd787600415eb207d9ae21d90445ca1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 2916, "upload_time": "2019-03-30T08:51:13", "url": "https://files.pythonhosted.org/packages/4f/ec/e9ec208deea3e7986c9814ed93f22813766400ee31824f54a4f89e0ca7ac/aiotimeout-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e11df65ac5b1c07268978899358722d2", "sha256": "ac98d5f3e8828af26b92e90dfc9ddad8e98b53b71d8e3794c0f9e8ebe759dd1a" }, "downloads": -1, "filename": "aiotimeout-0.0.2.tar.gz", "has_sig": false, "md5_digest": "e11df65ac5b1c07268978899358722d2", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 1828, "upload_time": "2019-03-30T08:51:15", "url": "https://files.pythonhosted.org/packages/e1/68/b50b7cd5b0ad53453d83708d965c1f227e39459e78e1d827532a0871914b/aiotimeout-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "e33e45a1f6b3e8a5d4e89653694e68d0", "sha256": "0289122c8d73958ba99a4040c0338fcc2dec2efc6c65b437eff3884db8d97e84" }, "downloads": -1, "filename": "aiotimeout-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "e33e45a1f6b3e8a5d4e89653694e68d0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 2920, "upload_time": "2019-03-30T08:56:46", "url": "https://files.pythonhosted.org/packages/c7/8e/f08bf325916cfa595f59a3af39693aedf1e62d23d5b54fa638bbd7a27f51/aiotimeout-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1f19c3ba2f03967415a015444f6fec95", "sha256": "a4938c78ff12ea5ab06263660dfa186606ad3c69639dba6ce66feaa65a6cb6a2" }, "downloads": -1, "filename": "aiotimeout-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1f19c3ba2f03967415a015444f6fec95", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 1828, "upload_time": "2019-03-30T08:56:47", "url": "https://files.pythonhosted.org/packages/32/a3/4a8dfb3e3fc7ef3c5303754e237d25dac2050e87a1d90f3b66621982820a/aiotimeout-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "798afe2cf2e058e8b710ebc0f52af538", "sha256": "729eb5056bd424d5018429f7e338b195c2153348271a50ebaea6d95ec9c67185" }, "downloads": -1, "filename": "aiotimeout-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "798afe2cf2e058e8b710ebc0f52af538", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 3077, "upload_time": "2019-03-30T09:52:51", "url": "https://files.pythonhosted.org/packages/83/77/102afcae8950b728e18141efc5b14ada3873f535eeedc4657ad93159ccbe/aiotimeout-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e8c1bac5ac459eb93b2632f8c9e2998", "sha256": "f237259423f3dac001f5cf4f75c7637ba914b623186eefd49b6a3d3b47bba0b9" }, "downloads": -1, "filename": "aiotimeout-0.0.4.tar.gz", "has_sig": false, "md5_digest": "3e8c1bac5ac459eb93b2632f8c9e2998", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 2033, "upload_time": "2019-03-30T09:52:53", "url": "https://files.pythonhosted.org/packages/90/9f/822949c457bc1bd54694a241b72e11096399e3d75bc75413e8acd23b636d/aiotimeout-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "798afe2cf2e058e8b710ebc0f52af538", "sha256": "729eb5056bd424d5018429f7e338b195c2153348271a50ebaea6d95ec9c67185" }, "downloads": -1, "filename": "aiotimeout-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "798afe2cf2e058e8b710ebc0f52af538", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 3077, "upload_time": "2019-03-30T09:52:51", "url": "https://files.pythonhosted.org/packages/83/77/102afcae8950b728e18141efc5b14ada3873f535eeedc4657ad93159ccbe/aiotimeout-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e8c1bac5ac459eb93b2632f8c9e2998", "sha256": "f237259423f3dac001f5cf4f75c7637ba914b623186eefd49b6a3d3b47bba0b9" }, "downloads": -1, "filename": "aiotimeout-0.0.4.tar.gz", "has_sig": false, "md5_digest": "3e8c1bac5ac459eb93b2632f8c9e2998", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 2033, "upload_time": "2019-03-30T09:52:53", "url": "https://files.pythonhosted.org/packages/90/9f/822949c457bc1bd54694a241b72e11096399e3d75bc75413e8acd23b636d/aiotimeout-0.0.4.tar.gz" } ] }