asyncer


Nameasyncer JSON
Version 0.0.8 PyPI version JSON
download
home_pageNone
SummaryAsyncer, async and await, focused on developer experience.
upload_time2024-08-24 23:15:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <a href="https://asyncer.tiangolo.com"><img src="https://asyncer.tiangolo.com/img/logo-margin/logo-margin-vector.svg" alt="Asyncer"></a>
</p>
<p align="center">
    <em>Asyncer, async and await, focused on developer experience.</em>
</p>
<p align="center">
<a href="https://github.com/fastapi/asyncer/actions?query=workflow%3ATest" target="_blank">
    <img src="https://github.com/fastapi/asyncer/workflows/Test/badge.svg" alt="Test">
</a>
<a href="https://github.com/fastapi/asyncer/actions?query=workflow%3APublish" target="_blank">
    <img src="https://github.com/fastapi/asyncer/workflows/Publish/badge.svg" alt="Publish">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/asyncer" target="_blank">
    <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/asyncer.svg" alt="Coverage">
<a href="https://pypi.org/project/asyncer" target="_blank">
    <img src="https://img.shields.io/pypi/v/asyncer?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
</p>

---

**Documentation**: <a href="https://asyncer.tiangolo.com" target="_blank">https://asyncer.tiangolo.com</a>

**Source Code**: <a href="https://github.com/fastapi/asyncer" target="_blank">https://github.com/fastapi/asyncer</a>

---

**Asyncer** is a small library built on top of <a href="https://anyio.readthedocs.io/en/stable/" class="external-link" target="_blank">AnyIO</a>.

**Asyncer** has a small number of utility functions that allow working with `async`, `await`, and concurrent code in a more convenient way under my (<a href="https://twitter.com/tiangolo" class="external-link" target="_blank">@tiangolo - Sebastián Ramírez</a>) very opinionated and subjective point of view.

The main goal of **Asyncer** is to improve **developer experience** by providing better support for **autocompletion** and **inline errors** in the editor, and **more certainty** that the code is **bug-free** by providing better support for type checking tools like **mypy**.

**Asyncer** also tries to improve **convenience** and simplicity when working with **async** code **mixed** with regular <abbr title="synchronous code, code that is not async">**blocking code**</abbr>, allowing to use them together in a simpler way... again, under my very **subjective** point of view.

## 🚨 Warning

This small library only exists to be able to use these **utility functions** until (and if) they are integrated into **AnyIO**.

It will probably take some time for that to happen (or to be decided if it will be included or not).

So I made this to be able to use these ideas right now. 🤓

## Can I Use It?

Yes 🎉 (but continue reading).

You can use this and evaluate the **library API design** I'm proposing. It will probably be useful to know if it works and is useful for you (I hope so).

But still, consider this lab material, expect it to change a bit. 🧪

If you use it, **pin the exact Asyncer version** for your project, to make sure it all works.

Have **tests** for your project (as you should, anyway). And **upgrade the version** once you know that the new version continues to work correctly.

Still, it's **just 4 functions**, so there's not much to change, if you had to refactor your code to update something it would not be much.

And if you don't want to add `asyncer` as a dependency to your project, you can also just copy the main file and try out those functions, it's quite small (but in that case you won't get updates easily).

## Requirements

As **Asyncer** is based on **AnyIO** it will be also installed automatically when you install **Asyncer**.

## Installation

<div class="termy">

```console
$ pip install asyncer
---> 100%
Successfully installed asyncer anyio
```

</div>

## How to Use

You can read more about each of the use cases and utility functions in **Asyncer** in the <a href="https://asyncer.tiangolo.com/tutorial/" class="external-link" target="_blank">tutorial</a>.

As a sneak preview of one of the utilities, you can **call sync code from async code** using `asyncify()`:

```Python
import time

import anyio
from asyncer import asyncify


def do_sync_work(name: str):
    time.sleep(1)
    return f"Hello, {name}"


async def main():
    message = await asyncify(do_sync_work)(name="World")
    print(message)


anyio.run(main)
```

**Asyncer**'s `asyncify()` will use AnyIO underneath to do *the smart thing*, avoid blocking the main **async** event loop, and run the **sync**/blocking function in a **worker thread**.

### Editor Support

Everything in **Asyncer** is designed to get the best **developer experience** possible, with the best editor support.

* **Autocompletion** for function arguments:

<img class="shadow" src="https://asyncer.tiangolo.com/img/tutorial/asyncify/image01.png">

* **Autocompletion** for return values:

<img class="shadow" src="https://asyncer.tiangolo.com/img/tutorial/asyncify/image02.png">

* **Inline errors** in editor:

<img class="shadow" src="https://asyncer.tiangolo.com/img/tutorial/soonify/image02.png">

* Support for tools like **mypy**, that can help you verify that your **code is correct**, and prevent many bugs.

## License

This project is licensed under the terms of the [MIT license](https://github.com/fastapi/asyncer/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "asyncer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "=?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ff/67/7ea59c3e69eaeee42e7fc91a5be67ca5849c8979acac2b920249760c6af2/asyncer-0.0.8.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <a href=\"https://asyncer.tiangolo.com\"><img src=\"https://asyncer.tiangolo.com/img/logo-margin/logo-margin-vector.svg\" alt=\"Asyncer\"></a>\n</p>\n<p align=\"center\">\n    <em>Asyncer, async and await, focused on developer experience.</em>\n</p>\n<p align=\"center\">\n<a href=\"https://github.com/fastapi/asyncer/actions?query=workflow%3ATest\" target=\"_blank\">\n    <img src=\"https://github.com/fastapi/asyncer/workflows/Test/badge.svg\" alt=\"Test\">\n</a>\n<a href=\"https://github.com/fastapi/asyncer/actions?query=workflow%3APublish\" target=\"_blank\">\n    <img src=\"https://github.com/fastapi/asyncer/workflows/Publish/badge.svg\" alt=\"Publish\">\n</a>\n<a href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/asyncer\" target=\"_blank\">\n    <img src=\"https://coverage-badge.samuelcolvin.workers.dev/fastapi/asyncer.svg\" alt=\"Coverage\">\n<a href=\"https://pypi.org/project/asyncer\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/v/asyncer?color=%2334D058&label=pypi%20package\" alt=\"Package version\">\n</a>\n</p>\n\n---\n\n**Documentation**: <a href=\"https://asyncer.tiangolo.com\" target=\"_blank\">https://asyncer.tiangolo.com</a>\n\n**Source Code**: <a href=\"https://github.com/fastapi/asyncer\" target=\"_blank\">https://github.com/fastapi/asyncer</a>\n\n---\n\n**Asyncer** is a small library built on top of <a href=\"https://anyio.readthedocs.io/en/stable/\" class=\"external-link\" target=\"_blank\">AnyIO</a>.\n\n**Asyncer** has a small number of utility functions that allow working with `async`, `await`, and concurrent code in a more convenient way under my (<a href=\"https://twitter.com/tiangolo\" class=\"external-link\" target=\"_blank\">@tiangolo - Sebasti\u00e1n Ram\u00edrez</a>) very opinionated and subjective point of view.\n\nThe main goal of **Asyncer** is to improve **developer experience** by providing better support for **autocompletion** and **inline errors** in the editor, and **more certainty** that the code is **bug-free** by providing better support for type checking tools like **mypy**.\n\n**Asyncer** also tries to improve **convenience** and simplicity when working with **async** code **mixed** with regular <abbr title=\"synchronous code, code that is not async\">**blocking code**</abbr>, allowing to use them together in a simpler way... again, under my very **subjective** point of view.\n\n## \ud83d\udea8 Warning\n\nThis small library only exists to be able to use these **utility functions** until (and if) they are integrated into **AnyIO**.\n\nIt will probably take some time for that to happen (or to be decided if it will be included or not).\n\nSo I made this to be able to use these ideas right now. \ud83e\udd13\n\n## Can I Use It?\n\nYes \ud83c\udf89 (but continue reading).\n\nYou can use this and evaluate the **library API design** I'm proposing. It will probably be useful to know if it works and is useful for you (I hope so).\n\nBut still, consider this lab material, expect it to change a bit. \ud83e\uddea\n\nIf you use it, **pin the exact Asyncer version** for your project, to make sure it all works.\n\nHave **tests** for your project (as you should, anyway). And **upgrade the version** once you know that the new version continues to work correctly.\n\nStill, it's **just 4 functions**, so there's not much to change, if you had to refactor your code to update something it would not be much.\n\nAnd if you don't want to add `asyncer` as a dependency to your project, you can also just copy the main file and try out those functions, it's quite small (but in that case you won't get updates easily).\n\n## Requirements\n\nAs **Asyncer** is based on **AnyIO** it will be also installed automatically when you install **Asyncer**.\n\n## Installation\n\n<div class=\"termy\">\n\n```console\n$ pip install asyncer\n---> 100%\nSuccessfully installed asyncer anyio\n```\n\n</div>\n\n## How to Use\n\nYou can read more about each of the use cases and utility functions in **Asyncer** in the <a href=\"https://asyncer.tiangolo.com/tutorial/\" class=\"external-link\" target=\"_blank\">tutorial</a>.\n\nAs a sneak preview of one of the utilities, you can **call sync code from async code** using `asyncify()`:\n\n```Python\nimport time\n\nimport anyio\nfrom asyncer import asyncify\n\n\ndef do_sync_work(name: str):\n    time.sleep(1)\n    return f\"Hello, {name}\"\n\n\nasync def main():\n    message = await asyncify(do_sync_work)(name=\"World\")\n    print(message)\n\n\nanyio.run(main)\n```\n\n**Asyncer**'s `asyncify()` will use AnyIO underneath to do *the smart thing*, avoid blocking the main **async** event loop, and run the **sync**/blocking function in a **worker thread**.\n\n### Editor Support\n\nEverything in **Asyncer** is designed to get the best **developer experience** possible, with the best editor support.\n\n* **Autocompletion** for function arguments:\n\n<img class=\"shadow\" src=\"https://asyncer.tiangolo.com/img/tutorial/asyncify/image01.png\">\n\n* **Autocompletion** for return values:\n\n<img class=\"shadow\" src=\"https://asyncer.tiangolo.com/img/tutorial/asyncify/image02.png\">\n\n* **Inline errors** in editor:\n\n<img class=\"shadow\" src=\"https://asyncer.tiangolo.com/img/tutorial/soonify/image02.png\">\n\n* Support for tools like **mypy**, that can help you verify that your **code is correct**, and prevent many bugs.\n\n## License\n\nThis project is licensed under the terms of the [MIT license](https://github.com/fastapi/asyncer/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Asyncer, async and await, focused on developer experience.",
    "version": "0.0.8",
    "project_urls": {
        "Changelog": "https://asyncer.tiangolo.com/release-notes/",
        "Documentation": "https://asyncer.tiangolo.com",
        "Homepage": "https://github.com/fastapi/asyncer",
        "Issues": "https://github.com/fastapi/asyncer/issues",
        "Repository": "https://github.com/fastapi/asyncer"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a0415b6ca6b7842eda2748bda0a0af73f2d054e9344320f8bba01f994294bcb",
                "md5": "148ef31eabc1ef2b9a7c03a5257c9ee3",
                "sha256": "5920d48fc99c8f8f0f1576e1882f5022885589c5fcbc46ce4224ec3e53776eeb"
            },
            "downloads": -1,
            "filename": "asyncer-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "148ef31eabc1ef2b9a7c03a5257c9ee3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9209,
            "upload_time": "2024-08-24T23:15:35",
            "upload_time_iso_8601": "2024-08-24T23:15:35.317252Z",
            "url": "https://files.pythonhosted.org/packages/8a/04/15b6ca6b7842eda2748bda0a0af73f2d054e9344320f8bba01f994294bcb/asyncer-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff677ea59c3e69eaeee42e7fc91a5be67ca5849c8979acac2b920249760c6af2",
                "md5": "48631493f5be58674177b1889685ae66",
                "sha256": "a589d980f57e20efb07ed91d0dbe67f1d2fd343e7142c66d3a099f05c620739c"
            },
            "downloads": -1,
            "filename": "asyncer-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "48631493f5be58674177b1889685ae66",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 18217,
            "upload_time": "2024-08-24T23:15:36",
            "upload_time_iso_8601": "2024-08-24T23:15:36.449007Z",
            "url": "https://files.pythonhosted.org/packages/ff/67/7ea59c3e69eaeee42e7fc91a5be67ca5849c8979acac2b920249760c6af2/asyncer-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-24 23:15:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fastapi",
    "github_project": "asyncer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "asyncer"
}
        
Elapsed time: 0.28130s