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
Close
Hashes for asyncio-atexit-1.0.0.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c2c4e1413f0c6a44aaf2439df4b64069186e839ae2d72478d45cf45feeffbc |
|
MD5 | a2a8a4acba88c94bf1bf9f790581a392 |
|
BLAKE2b-256 | 53c95767ece707b0f33a5426acd4f2bd19b1d9b29d4e5a50f1519c5ae49fc878 |
Close
Hashes for asyncio_atexit-1.0.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bc9e19947e13eaac5de8b112302bbf64e5c204c99d12378e0e60fd25d78075b |
|
MD5 | d68ee68b3c392cb3274843d42c9751cd |
|
BLAKE2b-256 | d57b93df64e870b95e517c41eebe006ad1c366b2f1ad1df2c77a7511b8d1985f |