mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-02-27 09:44:13 +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)
|
logging.error(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def receive(self):
|
def receive(self, timeout=1):
|
||||||
"""!Receive data from the server
|
"""!Receive data from the server
|
||||||
|
|
||||||
|
@param: timeout to wait for incoming data in seconds
|
||||||
@return received data"""
|
@return received data"""
|
||||||
try:
|
try:
|
||||||
read, _, _ = select.select([self._sock], [], [], 1)
|
read, _, _ = select.select([self._sock], [], [], timeout)
|
||||||
if not read: # check if there is something to read
|
if not read: # check if there is something to read
|
||||||
return False
|
return False
|
||||||
header = self._sock.recv(HEADERSIZE)
|
header = self._sock.recv(HEADERSIZE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue