3

I have a bunch of processes that run continuously on my server. I can modify the invocation command, but it is difficult to kill the process just to get the coverage report. As I understand it, the .coverage file is generated only after the process starts terminating. Is there any way around this?

Thanks.

Karthick
  • 4,456
  • 7
  • 28
  • 34
  • Coverage reports are intented for unittests and unittests should terminate. I guess your testing approach (if there is one) might be the root of the problem. – Klaus D. Nov 07 '16 at 06:10
  • Not sure I have a way for you to do that. Maybe you could suggest an API you'd like to see... – Ned Batchelder Nov 07 '16 at 16:00
  • 1
    BTW: this is a duplicate question: http://stackoverflow.com/questions/39485731/python-running-coverage-on-never-ending-process, but SO won't let me mark it as such because it also has no answer. – Ned Batchelder Nov 07 '16 at 16:25
  • Thanks for the response Ned! Would it be possible to add an option where the coverage dumps an intermediate .coverage file every n seconds or n operations/lines? – Karthick Nov 08 '16 at 04:11
  • Klaus, are you suggesting I shouldn't use coverage reports if I want to figure out which sections of the code are hit more often in a (pseudo-)production environment? Is there a better way to do this? – Karthick Nov 08 '16 at 04:16

1 Answers1

0

You can use pyrasite or lptrace

See this answer for details.

Community
  • 1
  • 1
amirouche
  • 7,682
  • 6
  • 40
  • 94