Procházet zdrojové kódy

raise exception if on_startup() is called too late

Falko Schindler před 2 roky
rodič
revize
1dbfd6ec56
1 změnil soubory, kde provedl 2 přidání a 0 odebrání
  1. 2 0
      nicegui/lifecycle.py

+ 2 - 0
nicegui/lifecycle.py

@@ -14,6 +14,8 @@ def on_disconnect(self, handler: Union[Callable, Awaitable]):
 
 
 def on_startup(self, handler: Union[Callable, Awaitable]):
+    if globals.state == globals.State.STARTED:
+        raise RuntimeError('Unable to register another startup handler. NiceGUI has already been started.')
     globals.startup_handlers.append(handler)