Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
enhance socketpair code in tpool #167
tpool.setup() uses its own implementation of socket.socketpair().
The "sock" socket is not explicitly closed, which emits a
This change uses socket.socketpair() if available (which is now the case
My code is based on the new socket.socketpair() implementation for
Oh, tpool.setup() doesn't work on Windows. sock.bind(('', 0)) is used, but then sock.getsockname() returns ('0.0.0.0', port) where port is a random port number: the address 0.0.0.0 is not valid.
csock.connect(sock.getsockname()) raises the exception socket.error(WSAEADDRNOTAVAIL, ...) (error 10049).
Travis is failing, but failures don't look to be related to my changes.
If you don't want the whole change (use socket.socketpair if available, try/except and try/finally to ensure that sockets are closed in case of errors), the minimum changes are: