[issue27614] Race in test_docxmlrpc.py

2016-08-05 Thread earl.chew

earl.chew added the comment:

In the original code, the key to the failure I observed is:

# wait for port to be assigned
n = 1000
while n > 0 and PORT is None:
time.sleep(0.001)
n -= 1

This gives a fixed deadline for the server thread to create the DocXMLRPCServer 
instance and provide the corresponding TCP port on which it is listening.

If the server thread is late (or if an exception is thrown -- but this case 
might work out ok), the TCP port will not be available in the variable PORT. In 
this case, the client thread blunders on, and inadvertently fails because PORT 
== None.

Upon failure, the test case tries to complete by tearing down the test:

 def tearDown(self):
 self.client.close()
 
 self.evt.wait()

The test case waits for self.evt to indicate that the server has completed. 
However, the server thread is running this:

while numrequests > 0:
serv.handle_request()
numrequests -= 1

In other words, the test is deadlocked because the server is waiting to process 
requests (actually it's waiting for a single request) from the client, but the 
client has already given up and is waiting for the server thread to complete.

--

___
Python tracker 
<http://bugs.python.org/issue27614>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27614] Race in test_docxmlrpc.py

2016-07-25 Thread earl.chew

New submission from earl.chew:

The test test_docxmlrpc.py will sometimes hang because of a timing race.

I've verified that this code is the same up to version 3.5 and master at 
https://github.com/python/cpython/blob/master/Lib/test/test_docxmlrpc.py

A proposed patch is attached.

--
components: Library (Lib)
files: test_docxmlrpc.py
messages: 271279
nosy: earl.chew
priority: normal
severity: normal
status: open
title: Race in test_docxmlrpc.py
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file43881/test_docxmlrpc.py

___
Python tracker 
<http://bugs.python.org/issue27614>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com