[issue19875] test_getsockaddrarg occasional failure
koobs added the comment: Thank you for taking care of this Charles-François :) Requesting backport to 3.3 and 2.7 too please, both are open for fixes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Roundup Robot added the comment: New changeset 57e3c4ae37ea by Charles-François Natali in branch '2.7': Issue #19875: Fix random test_getsockaddrarg() failure. http://hg.python.org/cpython/rev/57e3c4ae37ea -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Charles-François Natali added the comment: Backported to 2.7 (don't know how Iforgot it). 3.3 is only open for security issues, so not backporting. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
koobs added the comment: Updating versions to reflect branch changes. Will come in handy for those tracking for manual packaging backports -- versions: +Python 2.7, Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Roundup Robot added the comment: New changeset 897c9e6ddb1a by Charles-François Natali in branch '3.4': Issue #19875: Fix random test_getsockaddrarg() failure. http://hg.python.org/cpython/rev/897c9e6ddb1a New changeset 619feea86ce4 by Charles-François Natali in branch 'default': Issue #19875: Fix random test_getsockaddrarg() failure. http://hg.python.org/cpython/rev/619feea86ce4 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Charles-François Natali added the comment: Should be fixed now, thanks! -- resolution: - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Mark Lawrence added the comment: Clearly the long term solution is to fix the problems in the cpython code referenced in msg205227, but in the short term is it worth attempting a work around as suggested in msg205131 ? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Charles-François Natali added the comment: Here's a patch. -- keywords: +patch Added file: http://bugs.python.org/file36070/find_unused_race.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___diff -r f7643c893587 Lib/test/test_socket.py --- a/Lib/test/test_socket.py Wed Jul 23 19:28:13 2014 +0100 +++ b/Lib/test/test_socket.py Thu Jul 24 19:43:26 2014 +0100 @@ -3,6 +3,7 @@ import errno import io +import itertools import socket import select import tempfile @@ -1147,17 +1148,24 @@ sock.close() def test_getsockaddrarg(self): -host = '0.0.0.0' +sock = socket.socket() +self.addCleanup(sock.close) port = support.find_unused_port() big_port = port + 65536 neg_port = port - 65536 -sock = socket.socket() -try: -self.assertRaises(OverflowError, sock.bind, (host, big_port)) -self.assertRaises(OverflowError, sock.bind, (host, neg_port)) -sock.bind((host, port)) -finally: -sock.close() +self.assertRaises(OverflowError, sock.bind, (HOST, big_port)) +self.assertRaises(OverflowError, sock.bind, (HOST, neg_port)) +# Since find_unused_port() is inherently subject to race conditions, we +# call it a couple times if necessary. +for i in itertools.count(): +port = support.find_unused_port() +try: +sock.bind((HOST, port)) +except OSError as e: +if e.errno != errno.EADDRINUSE or i == 5: +raise +else: +break @unittest.skipUnless(os.name == nt, Windows specific) def test_sock_ioctl(self): ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
John W. O'Brien added the comment: For reference: CPython code comments showing that this may be an anticipated problem: http://hg.python.org/cpython/file/0830670a9d9d/Lib/test/support/__init__.py#l562 An example of another project that seems to have tackled this problem in the way neologix suggests: http://openvswitch.org/pipermail/dev/2013-April/026430.html I am inclined to frame this issue as a choice between LBYL (try to predict, subject to the race, whether a port will be available) and EAFP (blindly try a few random high ports before inferring failure). -- nosy: +neirbowj ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
New submission from Antoine Pitrou: It's on the FreeBSD 10.0 buildbot: http://buildbot.python.org/all/builders/AMD64%20FreeBSD%2010.0%203.x/builds/1169 == ERROR: test_getsockaddrarg (test.test_socket.GeneralModuleTests) -- Traceback (most recent call last): File /usr/home/buildbot/koobs-freebsd10/3.x.koobs-freebsd10/build/Lib/test/test_socket.py, line 1159, in test_getsockaddrarg sock.bind((host, port)) OSError: [Errno 48] Address already in use -- components: Library (Lib), Tests messages: 205099 nosy: koobs, neologix, pitrou priority: normal severity: normal status: open title: test_getsockaddrarg occasional failure type: behavior versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
Charles-François Natali added the comment: This test is inherently subject to a race condition: port = support.find_unused_port() [...] try: self.assertRaises(OverflowError, sock.bind, (host, big_port)) self.assertRaises(OverflowError, sock.bind, (host, neg_port)) sock.bind((host, port)) finally: sock.close() The buildbot being set up ton run the test suite with -j4 is probably the most important factor. A possibility would be to try the find_unused_port() + bind() in a loop a couple times. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19875 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com