File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 30
30
import struct
31
31
import subprocess
32
32
import threading
33
+ import time
33
34
35
+ from future .builtins import range # pylint: disable=redefined-builtin
34
36
from pysc2 import run_configs
35
37
from pysc2 .env import sc2_env
36
38
from pysc2 .lib import run_parallel
@@ -82,8 +84,15 @@ def tcp_client(tcp_addr):
82
84
"""Connect to the tcp server, and return the settings."""
83
85
family = socket .AF_INET6 if ":" in tcp_addr .ip else socket .AF_INET
84
86
sock = socket .socket (family , socket .SOCK_STREAM , socket .IPPROTO_TCP )
85
- logging .info ("Connecting to: %s" , tcp_addr )
86
- sock .connect (tcp_addr )
87
+ for i in range (300 ):
88
+ logging .info ("Connecting to: %s, attempt %d" , tcp_addr , i )
89
+ try :
90
+ sock .connect (tcp_addr )
91
+ break
92
+ except socket .error :
93
+ time .sleep (1 )
94
+ else :
95
+ sock .connect (tcp_addr ) # One last try, but don't catch this error.
87
96
logging .info ("Connected." )
88
97
89
98
map_data = read_tcp (sock )
You can’t perform that action at this time.
0 commit comments