diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/multiprocessing/connection.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 090796e..530a8df 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -249,10 +249,14 @@ class SocketListener(object): ''' def __init__(self, address, family, backlog=1): self._socket = socket.socket(getattr(socket, family)) - self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self._socket.bind(address) - self._socket.listen(backlog) - self._address = self._socket.getsockname() + try: + self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self._socket.bind(address) + self._socket.listen(backlog) + self._address = self._socket.getsockname() + except socket.error: + self._socket.close() + raise self._family = family self._last_accepted = None |