Skip to content

Commit

Permalink
fix: Add check of socket in outputs and inputs in API class
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius-P1 committed Jun 22, 2024
1 parent 7dfaf7d commit 086e0bf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ai/src/Network/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def sendData(self, data : str, timeout : int = None):
the timeout to wait for the server to be ready to receive data
(default is None which means no timeout)
"""
if -1 in self.outputs:
return
_, write, _ = select.select([], self.outputs, [], timeout)

if data[-1] != '\n':
Expand All @@ -109,6 +111,8 @@ def receiveData(self, timeout : float = None):
the timeout to wait for the server to send data
(default is None which means no timeout)
"""
if -1 in self.inputs:
return None
readable, _, _ = select.select(self.inputs, [], [], timeout)
for s in readable:
if s == self.sock:
Expand Down

0 comments on commit 086e0bf

Please sign in to comment.