Skip to content

Commit af86c07

Browse files
committed
added timeout to ping function
help alleviate issues where socket is open but unresponsive and ends up blocking the entire webui
1 parent 654dd62 commit af86c07

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mineos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,12 +908,13 @@ def server_list_packet():
908908
elif self.up:
909909
try:
910910
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
911+
s.settimeout(2.5)
911912
s.connect((self.ip_address, self.port))
912913
s.send(server_list_packet())
913914

914915
d = s.recv(1024)
915916
s.shutdown(socket.SHUT_RDWR)
916-
except socket.error:
917+
except (socket.error, socket.timeout):
917918
return error_ping
918919
finally:
919920
s.close()

0 commit comments

Comments
 (0)