Skip to content

Commit cd63e8e

Browse files
committed
Test fix for unit test
1 parent b55c7e7 commit cd63e8e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

salt/transport/zeromq.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,13 @@ def _send_recv(self, socket, _TimeoutError=salt.ext.tornado.gen.TimeoutError):
677677
log.trace(
678678
"The request ended with an error while sending. reconnecting."
679679
)
680+
# Only reconnect if the client is still active. If close() was
681+
# already called externally (context is None), do not create a
682+
# new socket/context that would never be cleaned up.
683+
_should_reconnect = self.context is not None
680684
self.close()
681-
self.connect()
685+
if _should_reconnect:
686+
self.connect()
682687
send_recv_running = False
683688
break
684689

@@ -724,8 +729,13 @@ def _send_recv(self, socket, _TimeoutError=salt.ext.tornado.gen.TimeoutError):
724729
)
725730
else:
726731
log.trace("The request ended with an error. reconnecting.")
732+
# Only reconnect if the client is still active. If close() was
733+
# already called externally (context is None), do not create a
734+
# new socket/context that would never be cleaned up.
735+
_should_reconnect = self.context is not None
727736
self.close()
728-
self.connect()
737+
if _should_reconnect:
738+
self.connect()
729739
send_recv_running = False
730740
elif received:
731741
data = salt.payload.loads(recv)

0 commit comments

Comments
 (0)