Metadata-Version: 2.1
Name: graceful-exit
Version: 1.0.0
Summary: A flexible context manager for python to handle graceful termination of python programs
Author: Thim Lohse
License: MIT
Platform: unix
Platform: linux
Platform: osx
Platform: cygwin
Platform: win32
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: testing
License-File: LICENSE

# Python Graceful Exit Context Manager

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



# Installation

```bash
pip install -U graceful-exit
```


# How to use:

## Synchronous example
```python
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
```python
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()))
```
