Connect fix
Concurrent connect
s could happen, for example if a socket is not connected yet and
2 methods (e.g. read, write) are executed from different greenlets ; each method would
try to connect, and it can lead to a bad mix like this:
- socket is created (
self._fd != None
) from call A - socket is connected (call to
socket.connect()
) from call A - socket is created from call B
- socket is connected from call B => gevent switches to 'A calls' stack
- socket is read from call A =>
Broken pipe
(socket is created but not connected), self._fd is assigned to None - socket cannot be connected from call B since
self._fd
isNone
now
Hopefully using self._lock
solves the problem ?