[New-bugs-announce] [issue8576] test_support.find_unused_port can cause socket conflicts on Windows
report at bugs.python.org
Fri Apr 30 11:18:04 CEST 2010
New submission from Paul Moore <p.f.moore at gmail.com>:
test_support.find_unused_port attempts to find an unused port to use. The approach is fragile (as noted in the docstring) in certain cases. In particular, it appears that Windows takes a short time to free the socket after it is closed, meaning that when the caller tries to open a socket on the returned port number, it gets permission issues.
A sleep(0.1) just before returning the port number appears to address the issue, but this is not a proper solution.
http://msdn.microsoft.com/en-us/library/ms737582%28v=VS.85%29.aspx describes the SO_LINGER and SO_DONTLINGER socket options, which may be related, but in my initial tests I haven't been able to get these to work.
components: Tests, Windows
title: test_support.find_unused_port can cause socket conflicts on Windows
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce