mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-24 00:29:53 -05:00
browser.py - Fix port search logic
This commit is contained in:
parent
8e84465ff9
commit
1f7f55a14a
@ -156,14 +156,13 @@ class Browser:
|
|||||||
def _find_available_port(self):
|
def _find_available_port(self):
|
||||||
port_available = False
|
port_available = False
|
||||||
port = self.chrome_port
|
port = self.chrome_port
|
||||||
while not port_available:
|
|
||||||
for connection in psutil.net_connections(kind='tcp'):
|
for p in range(port,65535):
|
||||||
if connection.laddr[1] == port:
|
if any(connection.laddr[1] == p for connection in psutil.net_connections(kind='tcp')):
|
||||||
self.logger.warn("Port already open %s", port)
|
self.logger.warn("Port already open %s, will try %s", p, p + 1)
|
||||||
port_available = False
|
else:
|
||||||
port += 1
|
port = p
|
||||||
break
|
break
|
||||||
port_available = True
|
|
||||||
return port
|
return port
|
||||||
|
|
||||||
def is_running(self):
|
def is_running(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user