Close socket properly before the next iteration
This avoid the errors `[Errno 106] Transport endpoint is already connected` which are due to connections kept in TIME_WAIT state. We don't use socket.SO_REUSEADDR as it would make the first connection a special case compared to the following ones.
This commit is contained in:
@@ -161,6 +161,8 @@ AS $$
|
||||
except (socket.timeout, OSError, socket.error), ex:
|
||||
plpy.warning('could not connect to server %s:%d, %s' % (host, port, str(ex)))
|
||||
n_errors += 1
|
||||
finally:
|
||||
s.close()
|
||||
|
||||
t_connect = (t_stop - t_start) * 1000.0
|
||||
plpy.debug('TCP connection %s:%d time=%.2f ms' % (host, port, t_connect))
|
||||
|
||||
Reference in New Issue
Block a user