-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
Covered lines marked as missing after gevent.joinall. #841
Comments
This might be related to #663. I wrote a unit test and it passed with In case you want it, here is the failing unit test (with diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index 9d777afe..b3fac048 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -272,6 +272,16 @@ class ConcurrencyTest(CoverageTest):
code = SIMPLE.format(QLIMIT=self.QLIMIT)
self.try_some_code(code, "gevent", gevent)
+ def test_gevent_joinall(self):
+ code = """\
+ import gevent
+
+ greenlet = gevent.spawn(lambda: None)
+ gevent.joinall([greenlet])
+ print("covered after joinall")
+ """
+ self.try_some_code(code, "gevent", gevent, "covered after joinall\n")
+
def test_greenlet(self):
GREENLET = """\
from greenlet import greenlet
diff --git a/tox.ini b/tox.ini
index bf636f27..b223f246 100644
--- a/tox.ini
+++ b/tox.ini
@@ -16,7 +16,7 @@ deps =
pip==19.1.1
setuptools==41.0.1
# gevent 1.3 causes a failure: https://github.com/nedbat/coveragepy/issues/663
- py{27,35,36}: gevent==1.2.2
+ py{27,35,36}: gevent==1.4.0
py{27,35,36,37,38}: eventlet==0.24.1
py{27,35,36,37,38}: greenlet==0.4.15 It fails with
|
@yury-primer you mention this might be related to #663. Are you on Windows? |
Never mind, I can see that the problem happens on Mac also. |
Yeah, I forgot to mention this is on Mac OS. Thanks for looking into it! |
I've written an issue on gevent to get some help: gevent/gevent#1471 |
Hi, I ran into this issue and did some debugging. I came across the bug when using sqlalchemy asyncio, that uses greenlet under the hood (see #1216 ). I created a test that tested this logic:
As noted above, the code after `gevent.joinall([greenlet]) does not get any coverage. I ran the coverage with the trace and logging in the CTracer. I noted that the covered lines have depth 0, but the lines that flag as no-coverage have depth 1. See the attached file for the complete dump.
Depth = 0, is present in the coverage report.
Depth = 1 which should be 0 I guess. Not present in the coverage report. I think that the gevent.joinall runs the rest of the code as a greenlet or something. I dont know. I pushed and popped the CALL / RET mentally and also came up with depth 1, so there is not much coverage can do I think. Perhaps it should record even if depth = 1? |
Alright, I figured it out. Adding the .coveragerc:
|
Describe the bug
Lines after a call to
gevent.joinall()
are reported as not covered even though they get run.To Reproduce
What version of Python are you running?
3.6.5
What versions of what packages do you have installed? The output of
pip freeze
is very helpful.test_foo.py:
coverage run --include=test_foo.py --concurrency=gevent -m test_foo
The above command should fail. Change the
4
to a5
to get it to pass.coverage report -m
This will indicate that two lines are not covered.
Expected behavior
Lines 13 and 14 clearly ran as they caused the test to fail. They should be reported as covered.
Additional context
Changing
gevent.joinall([greenlet])
togreenlet.join()
fixes the problem.The text was updated successfully, but these errors were encountered: