ソースを参照

removing auto-port detection for now

Rodja Trappe 2 年 前
コミット
8163b00fef
2 ファイル変更3 行追加17 行削除
  1. 3 6
      nicegui/run.py
  2. 0 11
      nicegui/standalone_mode.py

+ 3 - 6
nicegui/run.py

@@ -58,12 +58,6 @@ def run(*,
     '''
     globals.ui_run_has_been_called = True
 
-    if fullscreen:
-        standalone = True
-    if standalone:
-        port = standalone_mode.find_open_port()  # NOTE search for open port to avoid conflict with other apps
-        show = False
-
     globals.host = host
     globals.port = port
     globals.reload = reload
@@ -78,7 +72,10 @@ def run(*,
     if multiprocessing.current_process().name != 'MainProcess':
         return
 
+    if fullscreen:
+        standalone = True
     if standalone:
+        show = False
         width, height = (800, 600) if standalone is True else standalone
         standalone_mode.activate(f'http://localhost:{port}', title, width, height, fullscreen)
 

+ 0 - 11
nicegui/standalone_mode.py

@@ -28,14 +28,3 @@ def activate(url: str, title: str, width: int, height: int, fullscreen: bool) ->
     args = url, title, width, height, fullscreen, shutdown
     multiprocessing.Process(target=open_window, args=args, daemon=False).start()
     Thread(target=check_shutdown, daemon=True).start()
-
-
-def find_open_port(start_port: int = 8000, end_port: int = 8999) -> int:
-    for port in range(start_port, end_port + 1):
-        try:
-            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
-                s.bind(('localhost', port))
-                return port
-        except OSError:
-            pass
-    raise OSError('No open port found')