Skip to main content

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:

  1. accepts both coroutines and synchronous functions
  2. should be called from a running event loop
  3. calls registered cleanup functions when the event loop closes
  4. only works if the application running the event loop calls close()

Project details


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 details)

Uploaded Source

Built Distribution

asyncio_atexit-1.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file asyncio-atexit-1.0.1.tar.gz.

File metadata

  • Download URL: asyncio-atexit-1.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for asyncio-atexit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1d0c71544b8ee2c484d322844ee72c0875dde6f250c0ed5b6993592ab9f7d436
MD5 37671ea4890750fa84fe32214b282971
BLAKE2b-256 22d3dd2974be3f67c7ec96e0d6ab454429d0372cb7c7bffa3d0ac67a483cb801

See more details on using hashes here.

File details

Details for the file asyncio_atexit-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for asyncio_atexit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d93d5f7d5633a534abd521ce2896ed0fbe8de170bb1e65ec871d1c20eac9d376
MD5 120343fb1fe30226da19fb8fd72e9ea2
BLAKE2b-256 6510d6abaefa57a52646651fd0383c056280b0853c0106229ece6bb38cd14463

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page