<div dir="ltr"><div><div class="gmail_default" style="font-family:arial,sans-serif">(First and foremost, I think you need to explain more about what you&#39;ve tried so far. Beyond that, a<span style="font-family:Arial,Helvetica,sans-serif">s I&#39;ve just gone through issues using coverage.py in a multi-process setting, let me refer you to my recent message and the thread it spawned:</span></div></div><br><a href="http://lists.idyll.org/pipermail/testing-in-python/2020-April/007353.html">http://lists.idyll.org/pipermail/testing-in-python/2020-April/007353.html</a><br><br>It seems you have a somewhat more complicated setup than I did, but I will point you to this section of the docs:<br><br><span class="gmail_default" style="font-family:arial,sans-serif"></span><a href="https://coverage.readthedocs.io/en/coverage-5.1/subprocess.html">https://coverage.readthedocs.io/en/coverage-5.1/subprocess.html</a><br><br><span class="gmail_default" style="font-family:arial,sans-serif">I advise you to read it carefully. I missed some things in my first go-round, in particular this:</span><div><span class="gmail_default" style="font-family:arial,sans-serif"><br></span></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span class="gmail_default" style="font-family:arial,sans-serif">Measuring coverage in sub-processes is a little tricky. When you spawn a sub-process, you are invoking Python to run your program. Usually, to get coverage measurement, you have to use coverage.py to run your program. Your sub-process <b>won’t be using coverage.py</b>, so we have to convince Python to use coverage.py even when not explicitly invoked.</span></div></blockquote><div><span class="gmail_default" style="font-family:arial,sans-serif"></span></div><div><span class="gmail_default" style="font-family:arial,sans-serif">(emphasis mine)</span></div><div><span class="gmail_default" style="font-family:arial,sans-serif"><br></span></div><div><span class="gmail_default" style="font-family:arial,sans-serif"></span>The documentation section on command line execution:<br><br><a href="https://coverage.readthedocs.io/en/coverage-5.1/cmd.html#execution">https://coverage.readthedocs.io/en/coverage-5.1/cmd.html#execution</a><br><br>has this to say about complex multi-threaded/process/event situations:<br><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">Coverage.py can measure multi-threaded programs by default. If you are using more exotic concurrency, with the multiprocessing, greenlet, eventlet, or gevent libraries, then coverage.py will get very confused. Use the --concurrency switch to properly measure programs using these libraries. Give it a value of multiprocessing, thread, greenlet, eventlet, or gevent. Values other than thread require the C extension.</blockquote><br>I imagine it might be impossible to achieve perfection, but perhaps with overlapping runs using different values for the --concurrency flag you might get acceptable output.<br><br>Skip Montanaro<br><br></div></div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 14, 2020 at 8:11 AM Sebastian M. Ernst &lt;<a href="mailto:ernst@pleiszenburg.de">ernst@pleiszenburg.de</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I am trying to use `coverage.py` inside QGIS (1, 2). QGIS is a large<br>
hybrid C++/Python Qt-based application.<br>
<br>
Long story short: I am running into what appear to be nondeterministic<br>
race conditions plus a bunch of other issues. After reading the manual,<br>
I am guessing that with respect to QGIS&#39; threads and Qt&#39;s event loops<br>
coverage.py is not meant to be used in this context ;)<br>
<br>
Question: Does anybody around here have any experience at all with<br>
coverage.py and QGIS or just coverage.py inside larger<br>
(C++/Qt/PyQt/hybrid) applications?<br>
<br>
Best regards,<br>
Sebastian<br>
<br>
<br>
1: <a href="https://www.qgis.org" rel="noreferrer" target="_blank">https://www.qgis.org</a><br>
2: <a href="https://github.com/qgis/QGIS" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS</a><br>
<br>
_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
</blockquote></div>