Skip to content

Add --sigterm flag #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

liammcinroy
Copy link

Adds a --sigterm flag (matching coverage.py's sigterm flag) to still write the coverage output if a SIGTERM signal is sent.

Helpful for using slipcover in e.g. docker containers.

Tested with a simple while True: ... script and then a kill -SIGTERM. I'm not too familiar with what sort of cleanup may be necessary for more complex cases, so I'd welcome any suggestions on how to truly gracefully exit.

Also, this currently ignores --fail-under, since it exits immediately instead. I'm happy to update it to e.g. raise an exception that is caught by a context manager surrounding the runpy / exec calls, so that the normal flow in __main__ afterwards is maintained. I chose not to for now, since the atexit isn't currently doing that either.

Thanks for creating/maintaining this project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant