mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-01-11 11:10:08 +01:00
add recv timeout for client
This commit is contained in:
parent
bf3914a693
commit
504728191d
|
|
@ -82,12 +82,13 @@ class TCPClient:
|
|||
logging.error(e)
|
||||
return False
|
||||
|
||||
def receive(self):
|
||||
def receive(self, timeout=1):
|
||||
"""!Receive data from the server
|
||||
|
||||
@param: timeout to wait for incoming data in seconds
|
||||
@return received data"""
|
||||
try:
|
||||
read, _, _ = select.select([self._sock], [], [], 1)
|
||||
read, _, _ = select.select([self._sock], [], [], timeout)
|
||||
if not read: # check if there is something to read
|
||||
return False
|
||||
header = self._sock.recv(HEADERSIZE)
|
||||
|
|
|
|||
Loading…
Reference in a new issue