enhance socketpair code in tpool

tpool.setup() uses its own implementation of socket.socketpair().

The "sock" socket is not explicitly closed, which emits a
ResourceWarning with Python 3 when warnings are enabled (ex: python3
-Wd).

This change uses socket.socketpair() if available (which is now the case
an all platforms since Python 3.5). It also ensures that the "sock"
socket is closed, and that all sockets are closed in case of error.

My code is based on the new socket.socketpair() implementation for
Windows in Python 3.5.