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.0.dev0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

asyncio_atexit-1.0.0.dev0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

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

Hashes for asyncio-atexit-1.0.0.dev0.tar.gz
Algorithm Hash digest
SHA256 d2c2c4e1413f0c6a44aaf2439df4b64069186e839ae2d72478d45cf45feeffbc
MD5 a2a8a4acba88c94bf1bf9f790581a392
BLAKE2b-256 53c95767ece707b0f33a5426acd4f2bd19b1d9b29d4e5a50f1519c5ae49fc878

See more details on using hashes here.

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

Hashes for asyncio_atexit-1.0.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 9bc9e19947e13eaac5de8b112302bbf64e5c204c99d12378e0e60fd25d78075b
MD5 d68ee68b3c392cb3274843d42c9751cd
BLAKE2b-256 d57b93df64e870b95e517c41eebe006ad1c366b2f1ad1df2c77a7511b8d1985f

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