classification
Title: test_asyncore: test_handle_write() fails in tearDown()
Type: Stage: resolved
Components: Tests Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: haypo
Priority: normal Keywords:

Created on 2017-04-19 22:54 by haypo, last changed 2017-07-04 14:52 by haypo. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1194 merged haypo, 2017-04-19 22:56
PR 1234 merged haypo, 2017-04-21 11:22
PR 1336 merged haypo, 2017-04-28 01:25
Messages (9)
msg291920 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-19 22:54
On the AMD64 FreeBSD CURRENT Non-Debug 3.x buildbot, test_handle_write() of test_asyncore now fails on calling asyncore.close_all() in tearDown().

Moreover, since my commit 7b9619ae249ed637924d1c76687b411061753e5a, the following test_quick_connect() now fails on self.fail("join() timed out"). I guess that asyncore.socket_map still contains unwanted sockets from test_handle_write() which failed.

Attached PR should fix the test_handle_write() failure by calling asyncore.close_all() with ignore_all=True.

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Non-Debug%203.x/builds/174/steps/test/logs/stdio

======================================================================
ERROR: test_handle_write (test.test_asyncore.TestAPI_UseIPv6Poll)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_asyncore.py", line 505, in tearDown
    asyncore.close_all()
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/asyncore.py", line 561, in close_all
    x.close()
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/asyncore.py", line 397, in close
    self.socket.close()
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/socket.py", line 417, in close
    self._real_close()
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/socket.py", line 411, in _real_close
    _ss.close(self)
ConnectionResetError: [Errno 54] Connection reset by peer

======================================================================
FAIL: test_quick_connect (test.test_asyncore.TestAPI_UseIPv6Poll)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/support/__init__.py", line 2042, in decorator
    return func(*args)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_asyncore.py", line 800, in test_quick_connect
    self.fail("join() timed out")
AssertionError: join() timed out
msg291927 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-20 00:55
New changeset 11470b6dcdbc170779499a4a040b93c842a0d194 by Victor Stinner in branch 'master':
bpo-30106: Fix tearDown() of test_asyncore (#1194)
https://github.com/python/cpython/commit/11470b6dcdbc170779499a4a040b93c842a0d194
msg291930 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-20 01:25
It seems like the change 11470b6dcdbc170779499a4a040b93c842a0d194 fixed test_handle_write(), but test_quick_connect() fails on thread.join().

test_quick_connect (test.test_asyncore.TestAPI_UseIPv4Poll) ... Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_asyncore.py", line 785, in <lambda>
    count=500))
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/asyncore.py", line 207, in loop
    poll_fun(timeout, map)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/asyncore.py", line 144, in poll
    r, w, e = select.select(r, w, e, timeout)
OSError: [Errno 9] Bad file descriptor

FAIL

test_quick_connect (test.test_asyncore.TestAPI_UseIPv4Select) ... Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_asyncore.py", line 785, in <lambda>
    count=500))
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/asyncore.py", line 207, in loop
    poll_fun(timeout, map)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/asyncore.py", line 144, in poll
    r, w, e = select.select(r, w, e, timeout)
OSError: [Errno 9] Bad file descriptor

FAIL

======================================================================
FAIL: test_quick_connect (test.test_asyncore.TestAPI_UseIPv4Poll)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/support/__init__.py", line 2042, in decorator
    return func(*args)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_asyncore.py", line 800, in test_quick_connect
    self.fail("join() timed out")
AssertionError: join() timed out

======================================================================
FAIL: test_quick_connect (test.test_asyncore.TestAPI_UseIPv4Select)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/support/__init__.py", line 2042, in decorator
    return func(*args)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_asyncore.py", line 800, in test_quick_connect
    self.fail("join() timed out")
AssertionError: join() timed out
msg291931 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-20 01:29
Since my change 7b9619ae249ed637924d1c76687b411061753e5a, test_asyncore now fails on the AMD64 FreeBSD CURRENT Debug 3.x buildbot, it wasn't the case before. First fail:
http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Debug%203.x/builds/174/
msg291933 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-20 01:46
I started to work on this issue because I noticed many "xxx modified by test_xxx" on the two FreeBSD CURRENT buildbots. Examples:

AMD64_FreeBSD_CURRENT_Debug_3.x/163:Warning -- threading._dangling was modified by test_logging

AMD64_FreeBSD_CURRENT_Debug_3.x/159:Warning -- asyncore.socket_map was modified by test_ssl
msg292026 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-21 11:23
> AssertionError: join() timed out

The following PR fixes this race condition which occurs on FreeBSD:
https://github.com/python/cpython/pull/1234 fixes
msg292027 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-21 11:51
New changeset a2c877c3985aba4adb19755e21f477e1c639cfd9 by Victor Stinner in branch 'master':
bpo-30106: Fix test_asyncore.test_quick_connect() (#1234)
https://github.com/python/cpython/commit/a2c877c3985aba4adb19755e21f477e1c639cfd9
msg292503 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-04-28 02:13
New changeset caa59c156d1e6ff3d005e0112bb27c5bed4afb71 by Victor Stinner in branch '3.6':
[3.6] bpo-30106: Fix test_asyncore.test_quick_connect() (#1336)
https://github.com/python/cpython/commit/caa59c156d1e6ff3d005e0112bb27c5bed4afb71
msg297663 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-07-04 14:52
File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/socket.py", line 411, in _real_close
    _ss.close(self)
ConnectionResetError: [Errno 54] Connection reset by peer


This bug was fixed by bpo-30319.
History
Date User Action Args
2017-07-04 14:54:42haypounlinkissue30319 dependencies
2017-07-04 14:52:46hayposetmessages: + msg297663
2017-06-03 22:26:56martin.panterlinkissue30319 dependencies
2017-05-02 22:46:23hayposetstatus: open -> closed
resolution: fixed
stage: resolved
2017-04-28 02:13:39hayposetmessages: + msg292503
2017-04-28 01:25:17hayposetpull_requests: + pull_request1447
2017-04-21 11:51:55hayposetmessages: + msg292027
2017-04-21 11:23:32hayposetmessages: + msg292026
2017-04-21 11:22:41hayposetpull_requests: + pull_request1352
2017-04-20 01:46:45hayposetmessages: + msg291933
2017-04-20 01:29:15hayposetmessages: + msg291931
2017-04-20 01:25:12hayposetmessages: + msg291930
2017-04-20 00:55:41hayposetmessages: + msg291927
2017-04-19 22:56:02hayposetpull_requests: + pull_request1320
2017-04-19 22:54:22haypocreate