Skip to main content

Asyncer, async and await, focused on developer experience.

Project description

Asyncer

Asyncer, async and await, focused on developer experience.

Test Publish Coverage Package version


Documentation: https://asyncer.tiangolo.com

Source Code: https://github.com/fastapi/asyncer


Asyncer is a small library built on top of AnyIO.

Asyncer has a small number of utility functions that allow working with async, await, and concurrent code in a more convenient way under my (@tiangolo - Sebastián Ramírez) 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 blocking code, allowing to use them together in a simpler way... again, under my very subjective point of view.

Can I Use It?

Yes 🎉 (but continue reading).

This is a very small library, there are things that can change and improve in the future.

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

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

How to Use

You can read more about each of the use cases and utility functions in Asyncer in the tutorial.

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

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:
  • Autocompletion for return values:
  • Inline errors in editor:
  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asyncer-0.0.14.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asyncer-0.0.14-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file asyncer-0.0.14.tar.gz.

File metadata

  • Download URL: asyncer-0.0.14.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for asyncer-0.0.14.tar.gz
Algorithm Hash digest
SHA256 501cba6a8f03ce24f7d9fe1f6a5af6fd155a98eee542f0898a4f43f6a4c2b67d
MD5 81d11bba71ce7d640363caf702852003
BLAKE2b-256 8fe0a1b5d54254f0f70828c3571785c05b47f0251839f0446a689da9fa3819b4

See more details on using hashes here.

File details

Details for the file asyncer-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: asyncer-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for asyncer-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 577fdf6da6f1cdcb4aebb94e44ca10c40e5662126b5c3ecb95f3ddf237c6dd6b
MD5 944c2b4a9af691fcc485a8b1769108c0
BLAKE2b-256 f1639690293fa269b081d52d0567583cd2c1243baf7a85c57f4673f973c6840b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page