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.1.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for asyncio_atexit-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d93d5f7d5633a534abd521ce2896ed0fbe8de170bb1e65ec871d1c20eac9d376 |
|
MD5 | 120343fb1fe30226da19fb8fd72e9ea2 |
|
BLAKE2b-256 | 6510d6abaefa57a52646651fd0383c056280b0853c0106229ece6bb38cd14463 |