##// END OF EJS Templates
don't allow gethostbyname(gethostname()) failure to crash ipcontroller...
MinRK -
Show More
@@ -192,7 +192,13 b' class IPControllerApp(BaseParallelApplication):'
192 except AssertionError:
192 except AssertionError:
193 pass
193 pass
194 else:
194 else:
195 try:
195 location = socket.gethostbyname_ex(socket.gethostname())[2][-1]
196 location = socket.gethostbyname_ex(socket.gethostname())[2][-1]
197 except (socket.gaierror, IndexError):
198 self.log.warn("Could not identify this machine's IP, assuming 127.0.0.1."
199 " You may need to specify '--location=<external_ip_address>' to help"
200 " IPython decide when to connect via loopback.")
201 location = '127.0.0.1'
196 cdict['location'] = location
202 cdict['location'] = location
197 fname = os.path.join(self.profile_dir.security_dir, fname)
203 fname = os.path.join(self.profile_dir.security_dir, fname)
198 with open(fname, 'wb') as f:
204 with open(fname, 'wb') as f:
@@ -166,8 +166,13 b' def disambiguate_ip_address(ip, location=None):'
166 """turn multi-ip interfaces '0.0.0.0' and '*' into connectable
166 """turn multi-ip interfaces '0.0.0.0' and '*' into connectable
167 ones, based on the location (default interpretation of location is localhost)."""
167 ones, based on the location (default interpretation of location is localhost)."""
168 if ip in ('0.0.0.0', '*'):
168 if ip in ('0.0.0.0', '*'):
169 try:
169 external_ips = socket.gethostbyname_ex(socket.gethostname())[2]
170 external_ips = socket.gethostbyname_ex(socket.gethostname())[2]
170 if location is None or location in external_ips:
171 except (socket.gaierror, IndexError):
172 # couldn't identify this machine, assume localhost
173 external_ips = []
174 if location is None or location in external_ips or not external_ips:
175 # If location is unspecified or cannot be determined, assume local
171 ip='127.0.0.1'
176 ip='127.0.0.1'
172 elif location:
177 elif location:
173 return location
178 return location
General Comments 0
You need to be logged in to leave comments. Login now