Skip to content

Commit 5595166

Browse files
authored
Dont try to update an instance that isnt running yet (#15998)
1 parent 4bdc185 commit 5595166

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/lightning_app/components/serve/streamlit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def run(self) -> None:
5858
],
5959
env=env,
6060
)
61+
self._process.wait()
6162

6263
def on_exit(self) -> None:
6364
if self._process is not None:

src/lightning_app/core/app.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,11 @@ def _update_layout(self) -> None:
526526
component._layout = layout
527527

528528
def _update_is_headless(self) -> None:
529-
is_headless = _is_headless(self)
529+
self.is_headless = _is_headless(self)
530530

531531
# If `is_headless` changed, handle it.
532532
# This ensures support for apps which dynamically add a UI at runtime.
533-
if self.is_headless != is_headless:
534-
self.is_headless = is_headless
535-
536-
_handle_is_headless(self)
533+
_handle_is_headless(self)
537534

538535
def _apply_restarting(self) -> bool:
539536
self._reset_original_state()

src/lightning_app/utilities/app_helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import websockets
2121
from deepdiff import Delta
22-
from lightning_cloud.openapi import AppinstancesIdBody, Externalv1LightningappInstance
22+
from lightning_cloud.openapi import AppinstancesIdBody, Externalv1LightningappInstance, V1LightningappInstanceState
2323

2424
import lightning_app
2525
from lightning_app.utilities.exceptions import LightningAppStateException
@@ -556,7 +556,12 @@ def _handle_is_headless(app: "LightningApp"):
556556
"App was not found. Please open an issue at https://github.com/lightning-AI/lightning/issues."
557557
)
558558

559-
if current_lightningapp_instance.spec.is_headless == app.is_headless:
559+
if any(
560+
[
561+
current_lightningapp_instance.spec.is_headless == app.is_headless,
562+
current_lightningapp_instance.status.phase != V1LightningappInstanceState.RUNNING,
563+
]
564+
):
560565
return
561566

562567
current_lightningapp_instance.spec.is_headless = app.is_headless

0 commit comments

Comments
 (0)