Skip to content

Commit 3a99a25

Browse files
authored
[App] Stop App when it has succeeded (#15801)
1 parent b682d4c commit 3a99a25

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/lightning_app/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3232
- Fixed debugging with VSCode IDE ([#15747](https://github.com/Lightning-AI/lightning/pull/15747))
3333

3434

35+
- Fixed the work not stopped when successful when passed directly to the LightningApp ([#15801](https://github.com/Lightning-AI/lightning/pull/15801))
36+
37+
3538
## [1.8.2] - 2022-11-17
3639

3740
### Added

src/lightning_app/core/flow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ def __init__(self, work):
758758
self.work = work
759759

760760
def run(self):
761+
if self.work.has_succeeded:
762+
self.work.stop()
763+
self._exit()
761764
self.work.run()
762765

763766
def configure_layout(self):

tests/tests_app/core/test_lightning_app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,3 +1134,14 @@ def test_lightning_flow_properties():
11341134
assert flow._value is None
11351135
flow.run()
11361136
assert flow._value is True
1137+
1138+
1139+
class SimpleWork2(LightningWork):
1140+
def run(self):
1141+
pass
1142+
1143+
1144+
def test_lightning_work_stopped():
1145+
1146+
app = LightningApp(SimpleWork2())
1147+
MultiProcessRuntime(app, start_server=False).dispatch()

0 commit comments

Comments
 (0)