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
{{ message }}
Repository navigation
Windows: Running the Python test suite sequentially is interrupted by (Pdb) prompt #88121
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-04-28.15:27:25.688>created_at=<Date2021-04-27.17:03:07.285>labels= ['3.10', 'OS-windows']
title='Windows: Running the Python test suite sequentially is interrupted by (Pdb) prompt'updated_at=<Date2021-04-28.15:27:25.687>user='https://github.com/shreyanavigyan'
Recent test failures have been noticed on Windows 10. The full test log has been attached. The tests test_distutils, test_pdb, test_signal and test_threading require a little bit of attention since there seems to be some kind of error.
I wonder if these four tests do something that affects all threads? The test driver module runs tests in parallel (if you ask it to run all or most tests, like the default).
I expect parallelism is a red herring: early in the test output attached to this report:
0:00:04 Run tests sequentially
and there's no other evidence in the output that multiple tests are running simultaneously.
Also on Win10, the 4 failing tests here pass for me if I run them one at a time, so it's not obvious.
I _suspect_ that what's going wrong with test_pdb is the root cause: every now & again, for some weeks now, when I try to run tests on Windows I come back to the cmd.exe window and see that it's just sitting there, waiting at a pdb prompt.
In the output attached to this report, note that after test_threading starts,
actually is manually entered by me. My tests also stop at that prompt but somehow entering these commands again allow us to continue. Why are the errors triggering at all? The tests that are failing when ran alongside the test suite haven't been messed with for a very long time now and still somehow out of the blue they are failing. Any thoughts?
Yes, I also see that pdb prompt. I recommend looking at what different
configurations are used by test.libregrtest.main() when no tests are passed
on the command line.
File "C:\github\cpython\lib\test\test_distutils.py", line 15, in <module>
import distutils.tests
File "C:\github\cpython\lib\contextlib.py", line 140, in __exit__
next(self.gen)
File "C:\github\cpython\lib\test\support\warnings_helper.py", line 179, in _filterwarnings
raise AssertionError("filter (%r, %s) did not catch any warning" %
AssertionError: filter ('The distutils package is deprecated', DeprecationWarning) did not catch any warning
Ah, test_distutils fails if distutils was already imported previously. The test should be fixed.
"""
test test_pdb failed -- Traceback (most recent call last):
File "C:\github\cpython\lib\doctest.py", line 2205, in runTestraiseself.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_issue_20766
File "C:\github\cpython\lib\test\test_pdb.py", line 1270, in test_pdb_issue_20766
"""
This is a surprising failure. No clue why test_pdb fails when other tests are run previously (when tests are run sequentially).
I think the test failures cascade, and some state is not being cleaned up. I'm trying to work through them now, but if someone else is as well, do say so and I'll find something else to do.
Then I removed all tests starting at test_signal, including test_signal. I removed slow tests like asyncio and multiprocessing tests.
shreyanavigyan commented on Apr 28, 2021
shreyanavigyanmannequin
MannequinAuthor
More actions
Another issue with the tests is that it has become terribly slow. It's taking about 45 minutes to complete 1 run of the test suite. A few days ago, it took only 10 - 15 minutes. And moreover I think test_threading is also modifying sys.gettrace. The logs have the full error message.
--Snippet--
0:33:17 load avg: 0.80 [307/426/2] test_signal
(Pdb) continue
Warning -- sys.gettrace was modified by test_signal
Before: None
After: <bound method Bdb.trace_dispatch of <pdb.Pdb object at 0x0000021A5D2DCD70>>
test test_signal failed -- Traceback (most recent call last):
File "C:\github\cpython\lib\test\test_signal.py", line 1345, in test_sigint
signal.raise_signal(signal.SIGINT)
AssertionError: KeyboardInterrupt not raised
--Snippet--
0:38:22 load avg: 0.04 [353/426/3] test_threading
(Pdb) continue
(Pdb) continue
(Pdb) continue
(Pdb) continue
Warning -- sys.gettrace was modified by test_threading
Before: None
After: <bound method Bdb.trace_dispatch of <pdb.Pdb object at 0x0000021A5D2DCD70>>
Shreyan Avigyan: please try an up to date version of the master branch, I fixed the Pdb issue with commit a09766d.
shreyanavigyan commented on Apr 28, 2021
shreyanavigyanmannequin
MannequinAuthor
More actions
Same errors.
(Recompilation was done 1 or 2 hours ago against the then updated master branch. It may not include the latest commit)
shreyanavigyan commented on Apr 28, 2021
shreyanavigyanmannequin
MannequinAuthor
More actions
FYI test_signal is no longer modifying sys.gettrace thanks to your fix. But test_threading still does. Do you have a fix for that?
shreyanavigyan commented on Apr 28, 2021
shreyanavigyanmannequin
MannequinAuthor
More actions
I ran the test again and test_signal still modifies sys.gettrace()
shreyanavigyan commented on Apr 28, 2021
shreyanavigyanmannequin
MannequinAuthor
More actions
All the test failures are side effects of other tests because when they are ran individually they do not trigger errors. Running sequentially causes the error.
I ran "python -m test" on an up to date master branch (commit fe52eb6), there is a single remaining issue. test_distutils failed because the deprecation warning was already emited: issue fixed by PR 25675. The other issues are gone.
Shreyan Avigyan: "Same errors."
IMO it's a mistake on your side. You ran an outdated version or you didn't rebuild Python cleanly.
"FYI test_signal is no longer modifying sys.gettrace thanks to your fix. But test_threading still does. (...) I ran the test again and test_signal still modifies sys.gettrace()"
It's not my case on my machine, again it sounds like an issue on your side.
Another issue with the tests is that it has become terribly slow. It's taking about 45 minutes to complete 1 run of the test suite. A few days ago, it took only 10 - 15 minutes.
It took 49 minutes on my Windows 10 VM. Are you sure that you ran the test suite sequentially when it was slower?
I advice you run using -j0 option to run tests in parallel: it's much faster, and it's also more reliable.
New changeset c1a9535 by Steve Dower in branch 'master': bpo-43955: Handle the case where the distutils warning has already been triggered (GH-25675) c1a9535
Activity
shreyanavigyan commentedon Apr 27, 2021
Recent test failures have been noticed on Windows 10. The full test log has been attached. The tests test_distutils, test_pdb, test_signal and test_threading require a little bit of attention since there seems to be some kind of error.
gvanrossum commentedon Apr 27, 2021
I wonder if these four tests do something that affects all threads? The test driver module runs tests in parallel (if you ask it to run all or most tests, like the default).
shreyanavigyan commentedon Apr 27, 2021
Pdb error source -
cpython/Lib/test/test_pdb.py
Line 1270 in 9aea31d
This is where the error in Pdb is originating from.
shreyanavigyan commentedon Apr 27, 2021
The test expects the <built-in default_int_handler> but gets sigint_handler method of a pdb.Pdb instance instead.
gvanrossum commentedon Apr 27, 2021
Can you submit a PR that fixes it?
tim-one commentedon Apr 27, 2021
I expect parallelism is a red herring: early in the test output attached to this report:
0:00:04 Run tests sequentially
and there's no other evidence in the output that multiple tests are running simultaneously.
Also on Win10, the 4 failing tests here pass for me if I run them one at a time, so it's not obvious.
I _suspect_ that what's going wrong with test_pdb is the root cause: every now & again, for some weeks now, when I try to run tests on Windows I come back to the cmd.exe window and see that it's just sitting there, waiting at a pdb prompt.
In the output attached to this report, note that after test_threading starts,
(Pdb) continue
(Pdb) continue
(Pdb) continue
(Pdb) continue
appears out of the blue. But test_pdb is long finished by that time.
But I'm clueless about current pdb internals.
shreyanavigyan commentedon Apr 27, 2021
Yes you're right. Running the failed tests individually does not trigger the errors. And the
(Pdb) continue
(Pdb) continue
(Pdb) continue
(Pdb) continue
actually is manually entered by me. My tests also stop at that prompt but somehow entering these commands again allow us to continue. Why are the errors triggering at all? The tests that are failing when ran alongside the test suite haven't been messed with for a very long time now and still somehow out of the blue they are failing. Any thoughts?
gvanrossum commentedon Apr 27, 2021
Yes, I also see that pdb prompt. I recommend looking at what different
configurations are used by test.libregrtest.main() when no tests are passed
on the command line.
vstinner commentedon Apr 27, 2021
File "C:\github\cpython\lib\test\test_distutils.py", line 15, in <module>
import distutils.tests
File "C:\github\cpython\lib\contextlib.py", line 140, in __exit__
next(self.gen)
File "C:\github\cpython\lib\test\support\warnings_helper.py", line 179, in _filterwarnings
raise AssertionError("filter (%r, %s) did not catch any warning" %
AssertionError: filter ('The distutils package is deprecated', DeprecationWarning) did not catch any warning
Ah, test_distutils fails if distutils was already imported previously. The test should be fixed.
This is a surprising failure. No clue why test_pdb fails when other tests are run previously (when tests are run sequentially).
See also bpo-43960
vstinner commentedon Apr 27, 2021
Shreyan Avigyan:
Do you mean that you modified the Python source code? Does the issue go away if you revert your change or if you test a newly installed Python?
zooba commentedon Apr 27, 2021
I think the test failures cascade, and some state is not being cleaned up. I'm trying to work through them now, but if someone else is as well, do say so and I'll find something else to do.
8 remaining items
vstinner commentedon Apr 27, 2021
Running these 3 tests is enough to reproduce the issue:
-------------------
Moreover, my PR 25674 (bpo-43963) fix these tests.
vstinner commentedon Apr 27, 2021
FYI I used the following patch to debug this issue:
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 872f121127..ee2e1ff77f 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -546,6 +546,8 @@ def _callSetUp(self):
self.setUp()
And I used the following script:
---------------
I created the "tests" file using the command:
python -m test --list-tests > tests
Then I removed all tests starting at test_signal, including test_signal. I removed slow tests like asyncio and multiprocessing tests.
shreyanavigyan commentedon Apr 28, 2021
Another issue with the tests is that it has become terribly slow. It's taking about 45 minutes to complete 1 run of the test suite. A few days ago, it took only 10 - 15 minutes. And moreover I think test_threading is also modifying sys.gettrace. The logs have the full error message.
--Snippet--
--Snippet--
0:38:22 load avg: 0.04 [353/426/3] test_threading
(Pdb) continue
(Pdb) continue
(Pdb) continue
(Pdb) continue
Warning -- sys.gettrace was modified by test_threading
Before: None
After: <bound method Bdb.trace_dispatch of <pdb.Pdb object at 0x0000021A5D2DCD70>>
--Snippet--
vstinner commentedon Apr 28, 2021
Shreyan Avigyan: please try an up to date version of the master branch, I fixed the Pdb issue with commit a09766d.
shreyanavigyan commentedon Apr 28, 2021
Same errors.
(Recompilation was done 1 or 2 hours ago against the then updated master branch. It may not include the latest commit)
shreyanavigyan commentedon Apr 28, 2021
FYI test_signal is no longer modifying sys.gettrace thanks to your fix. But test_threading still does. Do you have a fix for that?
shreyanavigyan commentedon Apr 28, 2021
I ran the test again and test_signal still modifies sys.gettrace()
shreyanavigyan commentedon Apr 28, 2021
All the test failures are side effects of other tests because when they are ran individually they do not trigger errors. Running sequentially causes the error.
vstinner commentedon Apr 28, 2021
I ran "python -m test" on an up to date master branch (commit fe52eb6), there is a single remaining issue. test_distutils failed because the deprecation warning was already emited: issue fixed by PR 25675. The other issues are gone.
Shreyan Avigyan: "Same errors."
IMO it's a mistake on your side. You ran an outdated version or you didn't rebuild Python cleanly.
"FYI test_signal is no longer modifying sys.gettrace thanks to your fix. But test_threading still does. (...) I ran the test again and test_signal still modifies sys.gettrace()"
It's not my case on my machine, again it sounds like an issue on your side.
vstinner commentedon Apr 28, 2021
It took 49 minutes on my Windows 10 VM. Are you sure that you ran the test suite sequentially when it was slower?
I advice you run using -j0 option to run tests in parallel: it's much faster, and it's also more reliable.
== Tests result: FAILURE ==
384 tests OK.
1 test failed:
test_distutils
41 tests skipped:
test_curses test_dbm_gnu test_dbm_ndbm test_devpoll test_epoll
test_fcntl test_fork1 test_gdb test_grp test_ioctl test_kqueue
test_multiprocessing_fork test_multiprocessing_forkserver test_nis
test_openpty test_ossaudiodev test_pipes test_poll test_posix
test_pty test_pwd test_readline test_resource test_smtpnet
test_socketserver test_spwd test_syslog test_threadsignals
test_timeout test_tix test_tk test_ttk_guionly test_urllib2net
test_urllibnet test_wait3 test_wait4 test_winsound test_xmlrpc_net
test_xxlimited test_xxtestfuzz test_zipfile64
Total duration: 49 min 12 sec
Tests result: FAILURE
zooba commentedon Apr 28, 2021
New changeset c1a9535 by Steve Dower in branch 'master':
bpo-43955: Handle the case where the distutils warning has already been triggered (GH-25675)
c1a9535
vstinner commentedon Apr 28, 2021
Thanks everyone for fixing these issues and thanks Shreyan for the bug report.
The main initial is now fixed, so I close the issue.
Let's continue the discussions in remaining open issues: