Skip to main content

Tiny helper for running your async code

Project description

😈 What the heck?

aioGo is the tiny helper library that doing two simple thinks:

  • run your async code

and

  • correct terminate your async code

Default python asyncio have troubles with this: when you hit Ctrl+C asyncio just cancel all your coroutines.

This can lead to many race conditions and hanging your application at exit point.

📘 How to use?

Install from pypi:

pip install aiogo

or, if you prefer poetry:

poetry add aiogo

And just:

from asyncio import Future
from aiogo import go

async def main(termination: Future[bool]) -> None:
    await termination

if __name__ == "__main__":
    go(main)

That's all. You just wait while termination future was resolved (when your application got SIGINT or SIGTERM).

When you will be use this library in real world, just:

import asyncio

async def main(termination: asyncio.Future[bool]) -> None:
    done, _ = asyncio.wait((termination, your_awesome_read_task), return_when=asyncio.FIRST_COMPLETED)

and check done set.

I want custom event loop (uvloop)!

That I have! Again, just:

import uvloop
from aiogo import go

go(main, event_loop_factory=uvloop.new_event_loop)

I want forced exit!

If you can't write correct exit behaviour, well... Do that:

from aiogo import go
go(main, exit_timeout=10)

And all your coroutines will be got CancelledError, as doing old good asyncio.run.

🌎 Hot to contribute?

  • Make a repository fork
  • Apply your changes (don't forget install pre-commit before making commit)
  • Make a pull request

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

aiogo-0.1.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

aiogo-0.1.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file aiogo-0.1.2.tar.gz.

File metadata

  • Download URL: aiogo-0.1.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Windows/10

File hashes

Hashes for aiogo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 14f9fb0feb240a773f27dfcf302f253996afa6a23f78cfb46b0258dbadcb6d3d
MD5 056261455880e8852fd17919382899aa
BLAKE2b-256 58b52cb58508a21bf3aa6fa03f9706dd5d5f064af1e12495010a54fc13df8429

See more details on using hashes here.

File details

Details for the file aiogo-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aiogo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Windows/10

File hashes

Hashes for aiogo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b2fc5e8712b35e92e8ae8daf800888f57ff8b367e1d3399c34e341b78e71d8c
MD5 c6403cd9ba33beb4e32acbe790e046e0
BLAKE2b-256 895e197ae8e59c5edb9d0f27d3ef01d176745150061b681bec86bae2a3440c8e

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