You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!shell
(virtualenv)2 rbu@localhost ~/code $ py.test
...
>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>
> some_test.py(48)test_should_not_create_duplicate_entries()
-> self.assert_increases_by(filler.fill, indexCache.query.count, 1)
(Pdb) c
................
(virtualenv)rbu@localhost ~/code $ py.test --looponfail
...
>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>
> some_test.py(48)test_should_not_create_duplicate_entries()
-> self.assert_increases_by(filler.fill, indexCache.query.count, 1)
(Pdb)
F...............
=================================== FAILURES ===================================
...
> if self.quitting: raise BdbQuit
E BdbQuit
################################ LOOPONFAILING #################################
...
############################# waiting for changes ##############################
### Watching: /home/rbu/code
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
This is py.test version 2.4.2, imported from .../pytest-2.4.2-py2.7.egg/pytest.pyc
setuptools registered plugins:
pytest-xdist-1.9 at .../pytest_xdist-1.9-py2.7.egg/xdist/plugin.pyc
Original comment byRobert Buchholz (BitBucket: rbuchholz, GitHub: rbuchholz):
Hey Holger, thanks for the reply. I haven't found anything in the documentation or xdist's web/pypi page, so I did not know this whether was intentional or known.
Now we have it documented.
Original comment byholger krekel (BitBucket: hpk42, GitHub: hpk42):
pytest-xdist manages a test slave process which collects and runs tests (at the control of the master process). However, it doesn't currently implement "stdout/stderr/stdin" forwarding. So it is this forwarding that is missing for making pdb() work. It's probably not very hard to implement this forwarding but requires understanding of execnet which is the underlying library for managing master-slave communication.
Closing as stalled, also this one is rather hard to do propperly
Reacted by Martin Becker, Alex Prinsen, Denys Korytkin, Jean Cruypenynck, Nil, Matthieu Bizien, Shuvo Saha, Sanchit Mathew, Iván Sánchez, Rick Elrod and 1 more
If you need to use PDB momentarily to troubleshoot, but don't want to rip out xdist, you can invoke it with the flags pytest -n0 --dist no which disables xdist entirely for that run (this also fixes the -s (stdout redirect) flag). Source: pytest-dev/pytest-xdist#231
Reacted by Cameron Garretson, Thomas Kolar, Oboleninov Anton and Matías Graña
Also, if you need to use a debugger, and you actually need test distribution (for example, because you are debugging a xdist-heisenbug that only happens when tests are distributed), you can use a remote debugger! python-remote-debug just solved that issue for me.
Reacted by kbehlers, Sander Maijers and Marc Herbert
Also, if you need to use a debugger, and you actually need test distribution (for example, because you are debugging a xdist-heisenbug that only happens when tests are distributed), you can use a remote debugger! python-remote-debug just solved that issue for me.
Great advice that worked for me until I moved the breakpoint close to where the xdist heisenbug happens, which... made the heisenbug disappear again :-(
Great advice that worked for me until I moved the breakpoint close to where the xdist heisenbug happens, which... made the heisenbug disappear again :-(
lmao, looks like you went on quite the 20 minute adventure there. A Python patch version update introducing a heisenbug is crazy. Seems like you solved your issue, happy to see that!
I'm wondering if it might have helped to bisect based on how close to the error path you can insert the breakpoint - would be interesting to see what gets messed up by adding it.
Not that you need it anymore, but also, anyone reading this is probably desperate and in a similar pickle, so here's an idea in case you're out of them!
xdist was apparently just the messenger. Not because it runs things in parallel, but (I'm guessing) because it offsets the stack size a little? Fascinating. But off-topic, so I'll shut up now (you can also "unsubscribe", this issue is closed!)
Activity
pytestbot commentedon Nov 20, 2013
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):
It's a known limitations that pytest-xdist and
--pdborpdb.set_trace()don't work. The former will error out immediately.pytestbot commentedon Nov 20, 2013
Original comment by Robert Buchholz (BitBucket: rbuchholz, GitHub: rbuchholz):
Hey Holger, thanks for the reply. I haven't found anything in the documentation or xdist's web/pypi page, so I did not know this whether was intentional or known.
Now we have it documented.
pytestbot commentedon Dec 18, 2013
Original comment by BitBucket: dwt, GitHub: dwt:
Uhm, nice to know that this is expected. Could you perhaps elaborate on why that is so? Could this be changed? Do you want this to change?
Thanks!
pytestbot commentedon Dec 18, 2013
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):
pytest-xdist manages a test slave process which collects and runs tests (at the control of the master process). However, it doesn't currently implement "stdout/stderr/stdin" forwarding. So it is this forwarding that is missing for making pdb() work. It's probably not very hard to implement this forwarding but requires understanding of execnet which is the underlying library for managing master-slave communication.
rbu commentedon Jun 20, 2015
@rbuchholz is actually @rbu on GitHub
RonnyPfannschmidt commentedon Jan 1, 2016
Closing as stalled, also this one is rather hard to do propperly
astockwell commentedon Jun 1, 2022
If you need to use PDB momentarily to troubleshoot, but don't want to rip out xdist, you can invoke it with the flags
pytest -n0 --dist nowhich disables xdist entirely for that run (this also fixes the -s (stdout redirect) flag). Source: pytest-dev/pytest-xdist#231ralokt commentedon Jan 10, 2023
Also, if you need to use a debugger, and you actually need test distribution (for example, because you are debugging a xdist-heisenbug that only happens when tests are distributed), you can use a remote debugger! python-remote-debug just solved that issue for me.
sanmai-NL commentedon Mar 12, 2025
@astockwell That doesn‘t work for me:
The
xdistplugin is still loaded, and the test hangs upon callingbreakpoint().marc-hb commentedon Feb 12, 2026
Great advice that worked for me until I moved the breakpoint close to where the xdist heisenbug happens, which... made the heisenbug disappear again :-(
Still recommended! There is a good chance it will work for you.
ralokt commentedon Feb 12, 2026
lmao, looks like you went on quite the 20 minute adventure there. A Python patch version update introducing a heisenbug is crazy. Seems like you solved your issue, happy to see that!
I'm wondering if it might have helped to bisect based on how close to the error path you can insert the breakpoint - would be interesting to see what gets messed up by adding it.
Not that you need it anymore, but also, anyone reading this is probably desperate and in a similar pickle, so here's an idea in case you're out of them!
marc-hb commentedon Feb 19, 2026
You've seen nothing - looks like I found an actual
cpythonbug in 3.13:xdistwas apparently just the messenger. Not because it runs things in parallel, but (I'm guessing) because it offsets the stack size a little? Fascinating. But off-topic, so I'll shut up now (you can also "unsubscribe", this issue is closed!)