Skip to content

Commit 6ae458a

Browse files
tchatonBorda
authored andcommitted
[App] Stop App when it has succeeded (#15801)
(cherry picked from commit 3a99a25)
1 parent aa6eb87 commit 6ae458a

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
@@ -49,6 +49,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4949
- Fixed the PyTorch Inference locally on GPU ([#15813](https://github.com/Lightning-AI/lightning/pull/15813))
5050

5151

52+
- Fixed the work not stopped when successful when passed directly to the LightningApp ([#15801](https://github.com/Lightning-AI/lightning/pull/15801))
53+
54+
5255
## [1.8.2] - 2022-11-17
5356

5457
### 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)