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
test_nntplib: sporadic failures, network isses? server down? #63955
Traceback (most recent call last):
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/test_nntplib.py", line 251, in wrapped
meth(self)
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/test_nntplib.py", line 201, in test_capabilities
resp, caps =self.server.capabilities()
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/nntplib.py", line 558, in capabilities
resp, lines =self._longcmdstring("CAPABILITIES")
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/nntplib.py", line 525, in _longcmdstring
resp, list=self._getlongresp(file)
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/nntplib.py", line 476, in _getlongresp
resp =self._getresp()
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/nntplib.py", line 449, in _getresp
resp =self._getline()
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/nntplib.py", line 432, in _getline
line =self.file.readline(_MAXLINE+1)
File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/socket.py", line 368, in readintoraiseOSError("cannot read from timed out object")
OSError: cannot read from timed out object
Traceback (most recent call last):
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/test/test_nntplib.py", line 298, in setUpClasscls.server =cls.NNTP_CLASS(cls.NNTP_HOST, timeout=TIMEOUT, usenetrc=False)
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 1071, in __init__
readermode=readermode, timeout=timeout)
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 334, in __init__self.getcapabilities()
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 390, in getcapabilities
resp, caps =self.capabilities()
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 558, in capabilities
resp, lines =self._longcmdstring("CAPABILITIES")
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 525, in _longcmdstring
resp, list=self._getlongresp(file)
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 476, in _getlongresp
resp =self._getresp()
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 449, in _getresp
resp =self._getline()
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/nntplib.py", line 437, in _getlineifnot line: raiseEOFError
EOFError
See bpo-1186900 about the NNTP client raising EOFError.
As for the “cannot read from timed out object” errors (also reported in bpo-19613), I think the test classes are bad. The test logs don’t seem to be available, but I reckon that the previous test to the failing test would have been skipped due to the transient Internet handler. The test classes are essentially coded like this:
classNetworkedNNTP_SSLTests(TestCase):
@classmethoddefsetUpClass(cls):
withsupport.transient_internet(cls.NNTP_HOST):
cls.server=NNTP_SSL(cls.NNTP_HOST, timeout=TIMEOUT)
deftest_that_triggered_the_failure(self):
withsupport.transient_internet(self.NNTP_HOST):
... # Suppose this timed out and the test was skippeddeftest_capabilities(self):
# Now this is reusing the existing connection, left in a broken state by# the previous testself.server.capabilities()
Either the server connection should be freshly made for each individual test case (not once per class), or all the test cases grouped by setUpClass() should be skipped if the transient Internet handler kicks in. I’m not sure if it is practical to do the second option with the standard unittest module. Perhaps the method wrapping stage could add some extra checks to see if the test should be skipped.
Test_with_statement() is a special case because it starts a fresh NNTP connection, rather than reusing self.server. Test_welcome() is also different because it does not send any new commands to the server. But I presume the other tests all try to reuse the old timed-out self.server object. The skipped messages are evidence of this.
The easy solution which I mentioned above would be to change setUpClass() to setUp(), although this might slow the tests down a bit, reconnecting to the remote server for each test method.
The solution that I prefer would be as Antoine suggested, to run our own server. I think expanding the server I created in bpo-25859 with more commands would be good enough.
Here is a diff that shows my changes better. I temporarily moved some classes back to their original positions to reduce the diff size, though it won’t work in practice because Python needs the classes defined before using them.
Multi-connect.patch is a smaller patch that changes setUpClass() → setUp(), so that each test method creates a new NNTP connection. The downside is all the reconnecting slows the test execution from 42 s down to 115 s, which is why I would like to move the testing to a local server.
I think it would be nice if tweaked support.transient_internet() to catch EADDRNOTAVAIL.
Sure, that sounds like a reasonable change? Do you want to work on a PR? If not, maybe we should open a new issue, since this issue is tidly linked to test_nntplib, whereas modifying support.transient_internet() is a more generic change.
Yeah, I will submit a pull request today. The reason I reopened this issue is that I didn't want to file another issue for a similar problem and wanted to use this as a meta issue for issues with test_nntplib. Also, I'd like to play Martin's patches a bit and see if they still needed.
Thanks for the reviews, Victor. I'm planning to work on them tonight. I will close this issue and open a new one if I decide to do further work on them.
PR 9461 converts Martin's nntp-server.patch. I've made some tweaks and fixed a "threading._dangling was modified by test_nntplib" warning. I will try to convert multi-connect.patch later.
I will attribute Martin as the patch author before merging the PR.
The original problem for which this issue as opened no longer appears to be affecting CPython (test_nntplib no longer sporadically fails, as far as I'm aware). Moreover, as @hugovk states, the nntplib module is now deprecated, and has no active maintainer in the core dev team. This means enhancements and bugfixes for the module are now considered low priority.
Given the large backlog of issues in the CPython repo, I am therefore closing this issue.
Activity
vstinner commentedon Nov 24, 2013
http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.x%203.x/builds/692/steps/test/logs/stdio
======================================================================
ERROR: test_capabilities (test.test_nntplib.NetworkedNNTP_SSLTests)
----------------------------------------------------------------------
http://buildbot.python.org/all/builders/x86%20OpenIndiana%203.x/builds/7147/steps/test/logs/stdio
======================================================================
ERROR: setUpClass (test.test_nntplib.NetworkedNNTP_SSLTests)
----------------------------------------------------------------------
pitrou commentedon Nov 24, 2013
The third-party server isn't extremely reliable indeed. Ideally, we would run our own NNTP server, but that's a lot more work.
BreamoreBoy commentedon Jul 17, 2014
Are these sporadic failures still happening? I've glanced over the logs and only found failures due to recent code changes.
vadmium commentedon Jun 21, 2015
See bpo-1186900 about the NNTP client raising EOFError.
As for the “cannot read from timed out object” errors (also reported in bpo-19613), I think the test classes are bad. The test logs don’t seem to be available, but I reckon that the previous test to the failing test would have been skipped due to the transient Internet handler. The test classes are essentially coded like this:
Either the server connection should be freshly made for each individual test case (not once per class), or all the test cases grouped by setUpClass() should be skipped if the transient Internet handler kicks in. I’m not sure if it is practical to do the second option with the standard unittest module. Perhaps the method wrapping stage could add some extra checks to see if the test should be skipped.
berkerpeksag commentedon Jun 17, 2016
I just saw the same test failures at http://buildbot.python.org/all/builders/AMD64%20Debian%20root%203.5/builds/998/steps/test/logs/stdio
I'm attaching the test logs for future reference.
vadmium commentedon Jun 17, 2016
Thanks Berker. In this case the previous tests using the same NNTP connection object were skipped. First run:
test_unknown_command (test.test_nntplib.NetworkedNNTPTests) ... ok
test_welcome (test.test_nntplib.NetworkedNNTPTests) ... ok
test_with_statement (test.test_nntplib.NetworkedNNTPTests) ... skipped "Resource 'news.trigofacile.com' is not available"
test_xhdr (test.test_nntplib.NetworkedNNTPTests) ... skipped "Resource 'news.trigofacile.com' is not available"
test_xover (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_zlogin (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_zzquit (test.test_nntplib.NetworkedNNTPTests) ... ERROR
Subsequent retry:
test_xover (test.test_nntplib.NNTPv2Tests) ... ok
test_article_head_body (test.test_nntplib.NetworkedNNTPTests) ... skipped "Resource 'news.trigofacile.com' is not available"
test_capabilities (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_date (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_description (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_descriptions (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_group (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_help (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_list (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_list_active (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_newgroups (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_over (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_unknown_command (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_welcome (test.test_nntplib.NetworkedNNTPTests) ... ok
test_with_statement (test.test_nntplib.NetworkedNNTPTests) ... ok
test_xhdr (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_xover (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_zlogin (test.test_nntplib.NetworkedNNTPTests) ... ERROR
test_zzquit (test.test_nntplib.NetworkedNNTPTests) ... ERROR
Test_with_statement() is a special case because it starts a fresh NNTP connection, rather than reusing self.server. Test_welcome() is also different because it does not send any new commands to the server. But I presume the other tests all try to reuse the old timed-out self.server object. The skipped messages are evidence of this.
The easy solution which I mentioned above would be to change setUpClass() to setUp(), although this might slow the tests down a bit, reconnecting to the remote server for each test method.
The solution that I prefer would be as Antoine suggested, to run our own server. I think expanding the server I created in bpo-25859 with more commands would be good enough.
vadmium commentedon Jun 19, 2016
Here is a patch that changes all affected tests to use a custom server running on localhost:
vadmium commentedon Jun 20, 2016
Here is a diff that shows my changes better. I temporarily moved some classes back to their original positions to reduce the diff size, though it won’t work in practice because Python needs the classes defined before using them.
vadmium commentedon Dec 24, 2016
Multi-connect.patch is a smaller patch that changes setUpClass() → setUp(), so that each test method creates a new NNTP connection. The downside is all the reconnecting slows the test execution from 42 s down to 115 s, which is why I would like to move the testing to a local server.
vstinner commentedon Apr 27, 2017
I wrote an obvious fix for this one: issue bpo-30188.
vstinner commentedon Jun 28, 2017
Any progress on this issue?
Martin: Can you please convert your latest patch into a Pull Request?
vstinner commentedon Sep 19, 2018
I didn't see test_nntplib failing recently, so I close the issue as outdated.
5 remaining items
vstinner commentedon Sep 20, 2018
Sure, that sounds like a reasonable change? Do you want to work on a PR? If not, maybe we should open a new issue, since this issue is tidly linked to test_nntplib, whereas modifying support.transient_internet() is a more generic change.
vstinner commentedon Sep 20, 2018
Oh, typo: you should read "Sure, that sounds like a reasonable change." :-)
berkerpeksag commentedon Sep 20, 2018
Yeah, I will submit a pull request today. The reason I reopened this issue is that I didn't want to file another issue for a similar problem and wanted to use this as a meta issue for issues with test_nntplib. Also, I'd like to play Martin's patches a bit and see if they still needed.
berkerpeksag commentedon Sep 20, 2018
New changeset 8213ead by Berker Peksag in branch 'master':
bpo-19756: Prevent test failures due to EADDRNOTAVAIL (GH-9446)
8213ead
berkerpeksag commentedon Sep 20, 2018
New changeset 4761770 by Berker Peksag (Miss Islington (bot)) in branch '3.7':
bpo-19756: Prevent test failures due to EADDRNOTAVAIL (GH-9446)
4761770
miss-islington commentedon Sep 20, 2018
New changeset 1eabe19 by Miss Islington (bot) in branch '3.6':
bpo-19756: Prevent test failures due to EADDRNOTAVAIL (GH-9446)
1eabe19
miss-islington commentedon Sep 20, 2018
New changeset 170ea8c by Miss Islington (bot) in branch '2.7':
bpo-19756: Prevent test failures due to EADDRNOTAVAIL (GH-9446)
170ea8c
vstinner commentedon Sep 20, 2018
Thanks Berker! Do you want to do something with Martin's patches? If not, can you please close the issue?
berkerpeksag commentedon Sep 20, 2018
Thanks for the reviews, Victor. I'm planning to work on them tonight. I will close this issue and open a new one if I decide to do further work on them.
berkerpeksag commentedon Sep 20, 2018
PR 9461 converts Martin's nntp-server.patch. I've made some tweaks and fixed a "threading._dangling was modified by test_nntplib" warning. I will try to convert multi-connect.patch later.
I will attribute Martin as the patch author before merging the PR.
cjerdonek commentedon May 22, 2020
See also: https://bugs.python.org/issue40735 (test_with_statement)
hugovk commentedon Apr 11, 2022
I think we can close this old issue and its PR because the nntplib module is deprecated in 3.11 and set for removal in 3.13?
See PEP 594 – Removing dead batteries from the standard library and #91217.
AlexWaygood commentedon Apr 12, 2022
@pitrou, @vstinner, @berkerpeksag, @vadmium, @miss-islington
The original problem for which this issue as opened no longer appears to be affecting CPython (
test_nntplibno longer sporadically fails, as far as I'm aware). Moreover, as @hugovk states, thenntplibmodule is now deprecated, and has no active maintainer in the core dev team. This means enhancements and bugfixes for the module are now considered low priority.Given the large backlog of issues in the CPython repo, I am therefore closing this issue.