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
Built Distribution
File details
Details for the file asyncio-atexit-1.0.0.dev0.tar.gz
.
File metadata
- Download URL: asyncio-atexit-1.0.0.dev0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.11.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c2c4e1413f0c6a44aaf2439df4b64069186e839ae2d72478d45cf45feeffbc |
|
MD5 | a2a8a4acba88c94bf1bf9f790581a392 |
|
BLAKE2b-256 | 53c95767ece707b0f33a5426acd4f2bd19b1d9b29d4e5a50f1519c5ae49fc878 |
File details
Details for the file asyncio_atexit-1.0.0.dev0-py3-none-any.whl
.
File metadata
- Download URL: asyncio_atexit-1.0.0.dev0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.11.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bc9e19947e13eaac5de8b112302bbf64e5c204c99d12378e0e60fd25d78075b |
|
MD5 | d68ee68b3c392cb3274843d42c9751cd |
|
BLAKE2b-256 | d57b93df64e870b95e517c41eebe006ad1c366b2f1ad1df2c77a7511b8d1985f |