Skip to content

Commit

Permalink
check for has_run_config before accessing its attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Nov 6, 2023
1 parent a1e1b31 commit e422483
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nicegui/nicegui.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def _get_component(key: str) -> FileResponse:
def _startup() -> None:
"""Handle the startup event."""
# NOTE ping interval and timeout need to be lower than the reconnect timeout, but can't be too low
sio.eio.ping_interval = max(app.config.reconnect_timeout * 0.8, 4)
sio.eio.ping_timeout = max(app.config.reconnect_timeout * 0.4, 2)
if not app.config.has_run_config:
raise RuntimeError('\n\n'
'You must call ui.run() to start the server.\n'
Expand All @@ -89,6 +87,8 @@ def _startup() -> None:
'remove the guard or replace it with\n'
' if __name__ in {"__main__", "__mp_main__"}:\n'
'to allow for multiprocessing.')
sio.eio.ping_interval = max(app.config.reconnect_timeout * 0.8, 4)
sio.eio.ping_timeout = max(app.config.reconnect_timeout * 0.4, 2)
if core.app.config.favicon:
if helpers.is_file(core.app.config.favicon):
app.add_route('/favicon.ico', lambda _: FileResponse(core.app.config.favicon)) # type: ignore
Expand Down

0 comments on commit e422483

Please sign in to comment.