asyncio-anywhere


Nameasyncio-anywhere JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/novex-ai/asyncio-anywhere
SummaryPython package that makes it easy to run fast asyncio code
upload_time2023-11-07 16:22:12
maintainer
docs_urlNone
authorBrad Ito
requires_python>=3.8,<4.0
licenseMIT
keywords python asyncio jupyter trio curio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # asyncio-anywhere
Python package that makes it easy to run fast asyncio code

[![PyPI version](https://badge.fury.io/py/asyncio-anywhere.svg)](https://badge.fury.io/py/asyncio-anywhere)
[![Release Notes](https://img.shields.io/github/release/novex-ai/asyncio-anywhere)](https://github.com/novex-ai/asyncio-anywhere/releases)
[![pytest](https://github.com/novex-ai/asyncio-anywhere/actions/workflows/pytest.yml/badge.svg?branch=main)](https://github.com/novex-ai/asyncio-anywhere/actions/workflows/pytest.yml)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)

Are you trying to run async code in Python and getting the error
`asyncio.run() cannot be called from a running event loop`?
This package makes it easy to run asyncio-based async code in tricky execution environments:

- [IPython](https://ipython.readthedocs.io/en/stable/)-based notebooks (JupyterLab, AWS Sagemaker, Databricks, etc)
- [trio](https://trio.readthedocs.io/en/stable/) applications
- [curio](https://curio.readthedocs.io/en/latest/) applications

Other Features:
- Use [uvloop](https://github.com/MagicStack/uvloop) for faster i/o - but without permanently changing the asyncio event loop policy
- Run any code which uses [asyncio](https://docs.python.org/3/library/asyncio.html) I/O.
- Type hints to support type-aware IDEs

Non-Features:
- asyncio-anywhere does not [monkey-patch](https://github.com/erdewit/nest_asyncio) the asyncio module.  This avoids unexpected
side-effects and potential future bugs.

## Usage

```sh
pip install asyncio-anywhere
```

```python
import asyncio
from asyncio_anywhere import asyncio_run


async def myfunc():
    await asyncio.sleep(0.01)
    return "OK"


result = asyncio_run(myfunc())

print(result)
```

Use `asyncio_run()` anywhere where you would normally have run [asyncio.run()](https://docs.python.org/3/library/asyncio-runner.html#asyncio.run).  Note that it also accepts a boolean `debug` parameter as the second parameter.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/novex-ai/asyncio-anywhere",
    "name": "asyncio-anywhere",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "python,asyncio,jupyter,trio,curio",
    "author": "Brad Ito",
    "author_email": "phlogisticfugu@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/b7/3f112a13354727538147119987dcb77bc619b46c325ea6c96c30c48f0a69/asyncio_anywhere-0.2.0.tar.gz",
    "platform": null,
    "description": "# asyncio-anywhere\nPython package that makes it easy to run fast asyncio code\n\n[![PyPI version](https://badge.fury.io/py/asyncio-anywhere.svg)](https://badge.fury.io/py/asyncio-anywhere)\n[![Release Notes](https://img.shields.io/github/release/novex-ai/asyncio-anywhere)](https://github.com/novex-ai/asyncio-anywhere/releases)\n[![pytest](https://github.com/novex-ai/asyncio-anywhere/actions/workflows/pytest.yml/badge.svg?branch=main)](https://github.com/novex-ai/asyncio-anywhere/actions/workflows/pytest.yml)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n\nAre you trying to run async code in Python and getting the error\n`asyncio.run() cannot be called from a running event loop`?\nThis package makes it easy to run asyncio-based async code in tricky execution environments:\n\n- [IPython](https://ipython.readthedocs.io/en/stable/)-based notebooks (JupyterLab, AWS Sagemaker, Databricks, etc)\n- [trio](https://trio.readthedocs.io/en/stable/) applications\n- [curio](https://curio.readthedocs.io/en/latest/) applications\n\nOther Features:\n- Use [uvloop](https://github.com/MagicStack/uvloop) for faster i/o - but without permanently changing the asyncio event loop policy\n- Run any code which uses [asyncio](https://docs.python.org/3/library/asyncio.html) I/O.\n- Type hints to support type-aware IDEs\n\nNon-Features:\n- asyncio-anywhere does not [monkey-patch](https://github.com/erdewit/nest_asyncio) the asyncio module.  This avoids unexpected\nside-effects and potential future bugs.\n\n## Usage\n\n```sh\npip install asyncio-anywhere\n```\n\n```python\nimport asyncio\nfrom asyncio_anywhere import asyncio_run\n\n\nasync def myfunc():\n    await asyncio.sleep(0.01)\n    return \"OK\"\n\n\nresult = asyncio_run(myfunc())\n\nprint(result)\n```\n\nUse `asyncio_run()` anywhere where you would normally have run [asyncio.run()](https://docs.python.org/3/library/asyncio-runner.html#asyncio.run).  Note that it also accepts a boolean `debug` parameter as the second parameter.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package that makes it easy to run fast asyncio code",
    "version": "0.2.0",
    "project_urls": {
        "Changelog": "https://github.com/novex-ai/asyncio-anywhere/releases",
        "Homepage": "https://github.com/novex-ai/asyncio-anywhere",
        "Issues": "https://github.com/novex-ai/asyncio-anywhere/issues",
        "Repository": "https://github.com/novex-ai/asyncio-anywhere"
    },
    "split_keywords": [
        "python",
        "asyncio",
        "jupyter",
        "trio",
        "curio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c01533fb8dfb1933676450fb4a8746ad929dcbeebe20faf916870942527c02e",
                "md5": "533ab6e50645ec126bc02dc051eee988",
                "sha256": "9cd0b9c5408dfb1334509f881f027ab118847b55bfd6226377531fbfe144c8be"
            },
            "downloads": -1,
            "filename": "asyncio_anywhere-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "533ab6e50645ec126bc02dc051eee988",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 4231,
            "upload_time": "2023-11-07T16:22:10",
            "upload_time_iso_8601": "2023-11-07T16:22:10.595860Z",
            "url": "https://files.pythonhosted.org/packages/5c/01/533fb8dfb1933676450fb4a8746ad929dcbeebe20faf916870942527c02e/asyncio_anywhere-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddb73f112a13354727538147119987dcb77bc619b46c325ea6c96c30c48f0a69",
                "md5": "3f1eb2f4ca2a475df4e93090b6f5daa4",
                "sha256": "5edcf2299978571c35e1b108d8b319a94192bd033037725a191ff317ca0da3c0"
            },
            "downloads": -1,
            "filename": "asyncio_anywhere-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3f1eb2f4ca2a475df4e93090b6f5daa4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 3630,
            "upload_time": "2023-11-07T16:22:12",
            "upload_time_iso_8601": "2023-11-07T16:22:12.152240Z",
            "url": "https://files.pythonhosted.org/packages/dd/b7/3f112a13354727538147119987dcb77bc619b46c325ea6c96c30c48f0a69/asyncio_anywhere-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-07 16:22:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "novex-ai",
    "github_project": "asyncio-anywhere",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "asyncio-anywhere"
}
        
Elapsed time: 0.17145s