Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5bab0f8

Browse files
committed
Backout the last hack and add in this new one.
The failure definitely seems timing related. This change *seems* to work. Since the failure isn't doesn't occur consistently, it's hard to tell. Running these tests on Solaris in this order: test_urllibnet test_operator test_cgi \ test_isinstance test_future test_ast test_logging generally caused a failure (about 50% of the time) before the sleep. I couldn't provoke the failure with the sleep. This should really be cleaned up by using threading.Events or something so it is not timing dependent and doesn't hang forever on failure.
1 parent 83cbb24 commit 5bab0f8

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

Lib/test/test_logging.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,12 @@ def __init__(self, host='localhost',
9898
self.abort = 0
9999
self.timeout = 1
100100

101-
def _wait_and_process_data(self):
102-
rd, wr, ex = select.select([self.socket.fileno()], [], [],
103-
self.timeout)
104-
if rd:
105-
self.handle_request()
106-
107101
def serve_until_stopped(self):
108102
while not self.abort:
109-
self._wait_and_process_data()
110-
111-
# XXX(nnorwitz): Try to fix timing related test failures.
112-
# It's possible self.aborted was set before the final message
113-
# was received. By calling _wait_and_process_data(),
114-
# it gives us one last chance to read messages.
115-
# The test generally only fails on Solaris.
116-
self._wait_and_process_data()
103+
rd, wr, ex = select.select([self.socket.fileno()], [], [],
104+
self.timeout)
105+
if rd:
106+
self.handle_request()
117107
#notify the main thread that we're about to exit
118108
socketDataProcessed.set()
119109
# close the listen socket
@@ -633,6 +623,10 @@ def test_main_inner():
633623

634624
rootLogger.addHandler(shdlr)
635625
test0()
626+
# XXX(nnorwitz): Try to fix timing related test failures.
627+
# This sleep gives us some extra time to read messages.
628+
# The test generally only fails on Solaris without this sleep.
629+
time.sleep(2.0)
636630
shdlr.close()
637631
rootLogger.removeHandler(shdlr)
638632

0 commit comments

Comments
 (0)