[Python-checkins] [python/cpython] caa59c: [3.6] bpo-30106: Fix test_asyncore.test_quick_conn...

GitHub noreply at github.com
Thu Apr 27 22:13:39 EDT 2017


  Branch: refs/heads/3.6
  Home:   https://github.com/python/cpython
  Commit: caa59c156d1e6ff3d005e0112bb27c5bed4afb71
      https://github.com/python/cpython/commit/caa59c156d1e6ff3d005e0112bb27c5bed4afb71
  Author: Victor Stinner <victor.stinner at gmail.com>
  Date:   2017-04-28 (Fri, 28 Apr 2017)

  Changed paths:
    M Lib/test/test_asyncore.py

  Log Message:
  -----------
  [3.6] bpo-30106: Fix test_asyncore.test_quick_connect() (#1336)

* Fix/optimize test_asyncore.test_quick_connect() (#1188)

Don't use addCleanup() in test_quick_connect() because it keeps the
Thread object alive and so @reap_threads fails on its timeout of 1
second. "./python -m test -v test_asyncore -m test_quick_connect"
now takes 185 ms, instead of 11 seconds.

Other minor changes:

* Use "with sock:" to close the socket instead of
  try/finally: sock.close()
* Use self.skipTest() in test_quick_connect() to remove one
  indentation level and notice user that the test is specific to
  AF_INET and AF_INET6

* bpo-30106: Fix tearDown() of test_asyncore (#1194)

Call asyncore.close_all() with ignore_all=True in the tearDown()
method of the test_asyncore base test case. It should prevent keeping
alive sockets in asyncore.socket_map if close() fails with an
unexpected error.

Revert also an unwanted change of my previous commit: remove name
parameter of Thread in test_quick_connect().

* bpo-30106: Fix test_asyncore.test_quick_connect() (#1234)

test_quick_connect() runs a thread up to 50 seconds, whereas the
socket is connected in 0.2 second and then the thread is expected to
end in less than 3 second. On Linux, the thread ends quickly because
select() seems to always return quickly. On FreeBSD, sometimes
select() fails with timeout and so the thread runs much longer than
expected.

Fix the thread timeout to fix a race condition in the test.




More information about the Python-checkins mailing list