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 hashes)
Built Distribution
Close
Hashes for asyncio_atexit-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b91ba7d3bd49a07838e85bdff75c23a26c69ce8ccb5ed1447d53d045012f2fd |
|
MD5 | a3b9c45eed00d318088b070064e9d6b8 |
|
BLAKE2b-256 | 85b4bbf2a1ac11f15cfe1abfce646be116e4283a029da5252bca12803b3645b6 |