mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-06-20 12:54:23 -04:00
browser.py - Fix port search logic
This commit is contained in:
parent
8e84465ff9
commit
1f7f55a14a
1 changed files with 7 additions and 8 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue