Describe the bug
If you have a long-running/daemon process that you're collecting coverage for, e.g. with coverage run long_running.py
, then even with the sigterm = true
setting the coverage data is not written if the process is killed with SIGTERM.
If the process is killed with SIGINT instead (either with Ctrl+C or kill -2 <pid>
) then data is successfully saved, presumably because this manifests as a python KeyboardInterrupt
exception that allows finally
blocks to be executed, whereas when SIGTERM is captured by coverage the original SIGTERM handler is invoked without saving data (finally
blocks do not get run).
To Reproduce
coverage debug sys
is helpful.
pip freeze
is helpful.
$cat handler.py
import os, signal
print("START", flush=True)
print("SIGTERM", flush=True)
os.kill(os.getpid(), signal.SIGTERM)
print("NOT HERE", flush=True)
$cat .coveragerc
[run]
sigterm = true
$coverage run handler.py
START
SIGTERM
Terminated
$ls -Al
-rw-r--r-- 1 legaul legaul 77 Apr 3 00:23 .coveragerc
-rw-r--r-- 1 legaul legaul 142 Apr 3 00:49 handler.py
Expected behavior
Expected coverage data file to be created.
Additional context
n/a
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4