Commit 9ee8235e authored by Patrick Dohmen's avatar Patrick Dohmen Committed by Corey Shields

Fix issue #312

Catch unexpected errors 32 and 98 in send() and bind()
parent 1e41233d
Pipeline #25351467 passed with stage
in 2 minutes and 8 seconds
......@@ -72,7 +72,11 @@ class Commsocket(object):
if not self.is_connected:
self.connect()
LOGGER.debug('Sending message: %s', message)
self.sock.send(message)
try:
self.sock.send(message)
except socket.error:
LOGGER.error('Cannot send to socket %s:%s', self.ip_address, self.port)
response = self.sock.recv(self._tasks_buffer_size)
LOGGER.debug('Received message: %s', response)
return response
......@@ -100,4 +104,10 @@ class Commsocket(object):
return conn
def bind(self):
self.sock.bind((self._tcp_ip, self._tcp_port))
try:
self.sock.bind((self._tcp_ip, self._tcp_port))
except socket.error:
LOGGER.error('Cannot bind socket %s:%s', self.ip_address, self.port)
self.sock.close()
self._connected = False
self.bind()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment