Skip to main content

Python Graceful Exit Context Manager

A flexible context manager for python to handle graceful termination of python programs

Installation

pip install -U graceful-exit

How to use:

Synchronous example

from graceful_exit.module import GracefulExit
from graceful_exit.helpers import wrap_in_system_exit

def main():
    app = App()
    with GracefulExit[App](
        app=app, exit_handler=app.exit_handler_sync
    ) as wrapped_app:
        wrapped_app.run_sync()

if __name__ == "__main__":
    wrap_in_system_exit(main())

Asynchronous example

from graceful_exit.module import GracefulExit
from graceful_exit.helpers import wrap_in_system_exit

async def main():
    app = App()
    async with GracefulExit[App](
        app=app, exit_handler=app.exit_handler_async
    ) as wrapped_app:
        await wrapped_app.run_async()

if __name__ == "__main__":
    wrap_in_system_exit(asyncio.run(main()))

Release files for graceful-exit 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graceful-exit 1.0.0
File Size Uploaded
graceful-exit-1.0.0.tar.gz 5.0 kB Details

Release files / graceful-exit-1.0.0.tar.gz

Download URL graceful-exit-1.0.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
126b8358a1bf155b960de18c6553393a366c0a9410c41276e4a34cce74ad6c9b
BLAKE2b-256 checksum
How to use checksums
13953c4c418963f6a0a505c24fc18235c29a6995d752702d2e8f14239d124d5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page