Spaces:
Sleeping
Sleeping
Update core/helper.py
Browse files- core/helper.py +4 -4
core/helper.py
CHANGED
|
@@ -5,20 +5,20 @@ class LifecycleHelper:
|
|
| 5 |
|
| 6 |
@classmethod
|
| 7 |
def initialize_if_possible(cls, ls: Lifecycle) -> None:
|
| 8 |
-
if isinstance(ls, Lifecycle) and ls.
|
| 9 |
ls.initialize()
|
| 10 |
|
| 11 |
@classmethod
|
| 12 |
def start_if_possible(cls, ls: Lifecycle) -> None:
|
| 13 |
-
if isinstance(ls, Lifecycle) and ls.
|
| 14 |
ls.start()
|
| 15 |
|
| 16 |
@classmethod
|
| 17 |
def stop_if_possible(cls, ls: Lifecycle) -> None:
|
| 18 |
-
if isinstance(ls, Lifecycle) and ls.
|
| 19 |
ls.stop()
|
| 20 |
|
| 21 |
@classmethod
|
| 22 |
def dispose_if_possible(cls, ls: Lifecycle) -> None:
|
| 23 |
-
if isinstance(ls, Lifecycle) and ls.
|
| 24 |
ls.dispose()
|
|
|
|
| 5 |
|
| 6 |
@classmethod
|
| 7 |
def initialize_if_possible(cls, ls: Lifecycle) -> None:
|
| 8 |
+
if isinstance(ls, Lifecycle) and ls.lifecycle_state.can_initialize(ls.lifecycle_state.phase):
|
| 9 |
ls.initialize()
|
| 10 |
|
| 11 |
@classmethod
|
| 12 |
def start_if_possible(cls, ls: Lifecycle) -> None:
|
| 13 |
+
if isinstance(ls, Lifecycle) and ls.lifecycle_state.can_start(ls.lifecycle_state.phase):
|
| 14 |
ls.start()
|
| 15 |
|
| 16 |
@classmethod
|
| 17 |
def stop_if_possible(cls, ls: Lifecycle) -> None:
|
| 18 |
+
if isinstance(ls, Lifecycle) and ls.lifecycle_state.can_stop(ls.lifecycle_state.phase):
|
| 19 |
ls.stop()
|
| 20 |
|
| 21 |
@classmethod
|
| 22 |
def dispose_if_possible(cls, ls: Lifecycle) -> None:
|
| 23 |
+
if isinstance(ls, Lifecycle) and ls.lifecycle_state.can_dispose(ls.lifecycle_state.phase):
|
| 24 |
ls.dispose()
|