Like atexit, but for asyncio
Project description
asyncio atexit
Adds atexit functionality to asyncio:
import asyncio_atexit
async def close_db():
await db_connection.close()
asyncio_atexit.register(close_db)
atexit is part of the standard library, and gives you a way to register functions to call when the interpreter exits.
asyncio doesn't have equivalent functionality to register functions when the event loop exits:
This package adds functionality that can be considered equivalent to atexit.register
,
but tied to the event loop lifecycle. It:
- accepts both coroutines and synchronous functions
- should be called from a running event loop
- calls registered cleanup functions when the event loop closes
- only works if the application running the event loop calls
close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asyncio-atexit-1.0.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file asyncio-atexit-1.0.0.tar.gz
.
File metadata
- Download URL: asyncio-atexit-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c6558ae2e5560f8470cc590593354343111f494f5e3f95fecd9a2fc31e3c631 |
|
MD5 | a2e4882596953d224d72ae8840fbc1a6 |
|
BLAKE2b-256 | ac088d9b049886376cc0e5f306e393163788b1b01c29f1bb14e983dd551422cb |
File details
Details for the file asyncio_atexit-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: asyncio_atexit-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b91ba7d3bd49a07838e85bdff75c23a26c69ce8ccb5ed1447d53d045012f2fd |
|
MD5 | a3b9c45eed00d318088b070064e9d6b8 |
|
BLAKE2b-256 | 85b4bbf2a1ac11f15cfe1abfce646be116e4283a029da5252bca12803b3645b6 |