Skip to content

Commit

Permalink
Prevented socket hanging on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
theonlydvr committed Sep 12, 2024
1 parent 3ac8565 commit 264de58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pybehave/Events/OENetworkLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class OENetworkLogger(EventLogger):

def __init__(self, name: str, address: str, port: str):
super().__init__(name)
context = zmq.Context()
self.context = zmq.Context()
self.fd = None
self.event_count = 0
self.socket = context.socket(zmq.REQ)
self.socket = self.context.socket(zmq.REQ)
self.socket.set(zmq.REQ_RELAXED, True)
self.socket.set(zmq.REQ_CORRELATE, True)
self.socket.setsockopt(zmq.LINGER, 5)
self.socket.connect("tcp://" + address + ":" + str(port))

def send_ttl_event(self, ec: int, ttl_type: str | float) -> None:
Expand Down
2 changes: 2 additions & 0 deletions pybehave/Events/OEWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def __init__(self, name: str, address: str, port: str):
self.event_count = 0
self.socket = context.socket(zmq.REQ)
self.socket.set(zmq.REQ_RELAXED, True)
self.socket.set(zmq.REQ_CORRELATE, True)
self.socket.setsockopt(zmq.LINGER, 5)
self.socket.connect("tcp://" + address + ":" + str(port))

self.layout = QVBoxLayout(self)
Expand Down
2 changes: 2 additions & 0 deletions pybehave/Sources/OESource.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def initialize(self):

self.out_socket = self.context.socket(zmq.REQ)
self.out_socket.set(zmq.REQ_RELAXED, True)
self.out_socket.set(zmq.REQ_CORRELATE, True)
self.out_socket.setsockopt(zmq.LINGER, 5)
self.out_socket.connect("tcp://" + self.address + ":" + str(self.out_port))

self.available = True
Expand Down

0 comments on commit 264de58

Please sign in to comment.