Mark Dickinson <dicki...@gmail.com> added the comment:

Thanks for the report.  I can reproduce this both on the py3k branch and the 
trunk.  It looks as though there's a race condition 
in the testShutDown/_testShutDown pair of methods in SocketConnectedTest.  If 
you add the line

time.sleep(0.01)

to the middle of the _testShutDown method in test_socket.py (between the 
self.serv_conn.send() and the self.serv_conn.shutdown), 
you'll probably find that this random occasional failure becomes a 99.9% 
reliable failure.

As far as I can tell, this is just a bug in test_socket itself, rather than a 
problem with the socket module.  I also can't see 
any reason why it should be Mac specific, but I don't have anything else handy 
to test on right now.

Suggested fix:  don't let testShutDown exit until after _testShutdown has 
executed the shutdown method.  Use a threading Event to 
make this work.  The attached patch (against the trunk) appears to fix the 
problem for me.  Martina, if you're in a position to 
test the patch, feedback would be welcome.

It would be good if someone could review this for sanity;  I'm a complete 
novice when it comes to threading (and sockets, for that 
matter).

----------
components:  -Library (Lib), Macintosh
keywords: +patch
nosy: +marketdickinson
priority:  -> normal
stage:  -> patch review
versions: +Python 2.6, Python 2.7, Python 3.1
Added file: http://bugs.python.org/file12384/issue4397.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4397>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to