Repository navigation
Closed
Labels
Description
Original report by Buck Evan (Bitbucket: bukzor, GitHub: bukzor).
I'm getting this kind of error with increasing frequency as I add tests to my project.
#!python
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/main.py", line 84, in wrap_session
INTERNALERROR> doit(config, session)
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/main.py", line 122, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/core.py", line 413, in __call__
INTERNALERROR> return self._docall(methods, kwargs)
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR> res = mc.execute()
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR> res = method(**kwargs)
INTERNALERROR> File "<remote exec>", line 59, in pytest_runtestloop
INTERNALERROR> File "<remote exec>", line 72, in run_tests
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/core.py", line 413, in __call__
INTERNALERROR> return self._docall(methods, kwargs)
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR> res = mc.execute()
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR> res = method(**kwargs)
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/pytest_timeout.py", line 70, in pytest_runtest_protocol
INTERNALERROR> timeout_setup(item)
INTERNALERROR> File "/home/travis/build/Yelp/venv-update/.tox/test/lib/python3.4/site-packages/pytest_timeout.py", line 95, in timeout_setup
INTERNALERROR> signal.signal(signal.SIGALRM, handler)
INTERNALERROR> ValueError: signal only works in main thread
Full detail:
Reacted by Ivan
Activity
pytest-timeout-bot commentedon Jun 9, 2015
Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).
Oops, apologies to miss the original report!
It seems like execnet must have changed where xdist's DSession is run and it is no longer run in the main thread. Not immediately sure what to do about this but I think you should be able to work around this by using
--timeout-method=thread.pytest-timeout-bot commentedon Dec 16, 2015
Original comment by Karthik Borkar (Bitbucket: [Karthik Borkar](https://bitbucket.org/Karthik Borkar), ).
Any update on this issue? hitting this regularly
pytest-timeout-bot commentedon Dec 16, 2015
Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).
@karthikborkar does the work-around fix it for you?
pytest-timeout-bot commentedon Dec 16, 2015
Original comment by Karthik Borkar (Bitbucket: [Karthik Borkar](https://bitbucket.org/Karthik Borkar), ).
@flub From https://pypi.python.org/pypi/pytest-timeout the
threadmethod has few downsides such asrelatively large overhead for running each test and that test runs are not completed. This means that other py.test features, like e.g. JUnit XML output or fixture teardown, will not function normally. fixture teardown and JUnit XML are important features which i need them to work correctlypytest-timeout-bot commentedon Dec 16, 2015
Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).
But it is the most reliable way of using pytest-timeout. pytest-timeout aims to be a last-resort attempt at finding problems that you otherwise would just be stuck with and not get any useful infor from. It's kind of misleading to think you can still continue your test run after a timeout occurred. And I do wonder if the default method is wrong because of this.
pytest-timeout-bot commentedon Feb 3, 2017
Original comment by Miguel Sánchez de León Peque (Bitbucket: Peque, GitHub: Peque).
I am getting the same kind of errors when using
pytest-timeoutwithpytest-xdist:https://travis-ci.org/Peque/osbrain/jobs/197634358
Using
--timeout-method=threadfixes this issue (i.e.: test suite completes) but, when a timeout actually occurs, the whole test suite gets stuck (just as if I didn't usepytest-timeout) and no useful stack-trace information is given. The output does not tell me which test timed-out either.pytest-timeout-bot commentedon May 12, 2018
Original comment by Bulat Gaifullin (Bitbucket: bgaifullin, GitHub: bgaifullin).
the issue affects me too.
pytest-timeout-bot commentedon May 13, 2018
Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).
So currently it seems pytest-timeout and pytest-xdist seem to work together fine, I ran this:
And the timeouts work. So I'll close this unless someone reopens with a reproducible example.
Thanks
pytest-timeout-bot commentedon May 15, 2018
Original comment by Darius Lapūnas (Bitbucket: DariusL, GitHub: DariusL).
Can still reproduce this. With pytest < 3.3 it would happen nearly every run, now it happens every fifth run or so.
Full output:
Keep in mind, I'm not actually triggering the timeout, it's much larger than the test can reasonably take. Runs fine without
-n4.pip list:
Running on Ubuntu 16.04. I have not noticed this issue on Windows or Mac.
pytest-timeout-bot commentedon May 15, 2018
Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).
Sorry, with your sample file in a loop I still can't reproduce this. I did a
pip install pytest pytest-timeout pytest-xdist. I even added pytest-forked as maybe a trigger but running the test in a loop still didn't trigger anything.Have you tried this in a complete clean environment? Or is there anything else hidden, like a config file or so (as otherwise pytest-forked wouldn't do anything)
pytest-timeout-bot commentedon May 16, 2018
Original comment by Darius Lapūnas (Bitbucket: DariusL, GitHub: DariusL).
Ok, so I tried redoing everything from scratch, these are my steps:
It failed on the second run. I also checked
which pytestjust in case and it's the one in my virtual environment.I'm not sure what other system information could be relevant. I'm seeing this both on my Ubuntu 16.04 VM (running in Parallels on a Mac) and on our Jenkins servers, also Ubuntu 16.04.
pytest-timeout-bot commentedon May 16, 2018
Original comment by Miguel Sánchez de León Peque (Bitbucket: Peque, GitHub: Peque).
I too think this should be reopened. See:
https://travis-ci.org/opensistemas-hub/osbrain/jobs/379614919
With:
pytest==3.5.1pytest-timeout==1.2.1pytest-xdist==1.22.2That is the result of trying to reintegrate
pytest-timeoutin osBrain with no other changes.pytest-timeout-bot commentedon Nov 24, 2018
Original comment by pombredanne NA (Bitbucket: pombredanne, GitHub: pombredanne).
I am not sure that pytest-timeout has anything to do with this directly.
FWIW I am getting the same kind of errors in scancode-toolkit test runs... but ONLY on Travis/Linux and not always.... kinda like every other run like others have reported here... and re-running the failed run makes the issue go away.
See https://travis-ci.org/nexB/scancode-toolkit/jobs/458977684#L1189
The tests I run are using pytest and xdist AND the underlying code supports timeout-based interruption in multiprocessing .
See https://github.com/nexB/scancode-toolkit/blob/develop/src/scancode/interrupt.py#L121
It could well be that the code I used for timeouts is using the same calls that pytest-timeout... which could explain why I am facing this too. In any case, I thought posting here could help
pytest-timeout-bot commentedon Nov 24, 2018
Original comment by pombredanne NA (Bitbucket: pombredanne, GitHub: pombredanne).
ok, my timeout handling code is functionally the same set of calls that pytest-timeout uses. So it makes sense to experience the same issues.
pytest-timeout-bot commentedon Nov 24, 2018
Original comment by pombredanne NA (Bitbucket: pombredanne, GitHub: pombredanne).
Now the interesting part is that pytest-xdist does not seem to be part of the problem either as Darius said above https://bitbucket.org/pytest-dev/pytest-timeout/issues/8/pytest-xdist-interop-signal-only-works-in#comment-45439827
So this seems to boil down t an issue between pytest and timout signals
11 remaining items
flub commentedon Jan 27, 2021
Hi @ndevenish, thanks for the explorations and additional info! The commit you point to is very interesting indeed. I'm a bit surprised that with xdist threaded mode can hang, I that'd be interesting to understand better as well.
Certainly do take this to a PR, at first glance I'm a bit torn on automatically switching to threaded vs just erroring out and forcing someone to decide this explicitly. But it would be nice to improve usability somehow and you found a pretty promising way I think.
(also, apologies I'm not always the most active, responses can take a while as you just noticed)
ndevenish commentedon Feb 1, 2021
I have no expectations for reply times for open source projects! I'll try to pull a PR together, for discussion if nothing else.
graingert commentedon Feb 3, 2021
@flub this should be fixed (mostly) on execnet==1.8.0
see also pytest-dev/pytest-xdist#620
ndevenish commentedon Feb 3, 2021
Ah, that's good to hear. I was settling on "Error, but with a more helpful suggestion" as the least-worst way to "fix", and didn't want to dig into execnet. Evidently it annoyed someone further than it annoyed me :)
flub commentedon Feb 3, 2021
@graingert oh, that's very nice work you did! Might finally fix this issue properly and would mean we don't need a workaround here.
use thread method if not main thread
use thread method if not main thread
use thread method if not main thread
pseudotensor commentedon Apr 27, 2021
Yes, we've gotten ever since using xdist + timeout together. It's fairly random:
use thread method if not main thread
use thread method if not main thread
xoviat commentedon May 18, 2021
@flub Can you close this?
flub commentedon Jun 21, 2021
I guess so, pytest-timeout now recognises this situation and will refuse to use the signal timeout method, falling back to the thread method.