mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-24 08:39:59 -05:00
without sudo, psutil.net_connections() raises psutil.AccessDenied on mac; in this case, silently try running chrome on the unvetted configured port
This commit is contained in:
parent
1141c5951e
commit
317a5eb99d
@ -157,9 +157,14 @@ class Browser:
|
||||
port_available = False
|
||||
port = self.chrome_port
|
||||
|
||||
for p in range(port,65535):
|
||||
if any(connection.laddr[1] == p for connection in psutil.net_connections(kind='tcp')):
|
||||
self.logger.warn("Port already open %s, will try %s", p, p + 1)
|
||||
try:
|
||||
conns = psutil.net_connections(kind="tcp")
|
||||
except psutil.AccessDenied:
|
||||
return port
|
||||
|
||||
for p in range(port, 65535):
|
||||
if any(connection.laddr[1] == p for connection in conns):
|
||||
self.logger.warn("port %s already open, will try %s", p, p+1)
|
||||
else:
|
||||
port = p
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user