A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nedbat/coveragepy/issues/1599 below:

Coverage data not saved on SIGTERM in 'concurrency = thread' mode · Issue #1599 · nedbat/coveragepy · GitHub

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

  1. What version of Python are you using?
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
  3. What versions of what packages do you have installed? The output of pip freeze is helpful.
  4. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
  5. What commands did you run?
$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