Skip to content

Commit 088cb70

Browse files
authored
Merge pull request #3922 from hove-io/jormungandr_count_socket
Count sockets
2 parents fed2574 + 30c3bbb commit 088cb70

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/jormungandr/jormungandr/transient_socket.py

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class TransientSocket(object):
6363
# the sorted list is arranged in a way that the first element is the most recent one and the last element is oldest
6464
# one.
6565
_logger = logging.getLogger(__name__)
66+
count_socket = {"total": 0}
6667

6768
def __init__(self, name, zmq_context, zmq_socket, socket_ttl, *args, **kwargs):
6869
super(TransientSocket, self).__init__(*args, **kwargs)
@@ -141,6 +142,10 @@ def call(self, content, timeout, debug_cb=lambda: "", quiet=False):
141142
else:
142143
with self._semaphore:
143144
self._sockets.add(timed_socket)
145+
# TODO: to remove after tests
146+
self.count_socket[self.name] = len(self._sockets)
147+
self.count_socket["total"] = sum([cnt for key, cnt in self.count_socket.items() if key != "total"])
148+
self._logger.info("Socket count: {}".format(self.count_socket))
144149

145150
def close_socket(self, socket):
146151
try:

0 commit comments

Comments
 (0)