Skip to content

Commit 96310f6

Browse files
committed
On closing UDP/TCP socket, make sure it is reset
This prevents re-using a possibly non-working socket instance in later send attempts which cannot work. Closes #89.
1 parent c60580b commit 96310f6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

logstash_async/transport.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ def _convert_data_to_send(self, data):
133133
def _close(self, force=False):
134134
if not self._keep_connection or force:
135135
if self._sock:
136-
self._wait_for_socket_buffer_empty()
137-
self._sock.shutdown(socket.SHUT_WR)
138-
self._sock.close()
139-
self._sock = None
136+
try:
137+
self._wait_for_socket_buffer_empty()
138+
self._sock.shutdown(socket.SHUT_WR)
139+
self._sock.close()
140+
finally:
141+
self._sock = None
140142

141143
# ----------------------------------------------------------------------
142144
def _wait_for_socket_buffer_empty(self):

0 commit comments

Comments
 (0)