File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,17 @@ def __init__(self) -> None:
136
136
"""Create a list of retsu tasks."""
137
137
self .tasks : dict [str , Task ] = {}
138
138
139
+ @public
140
+ def create_tasks (self ) -> None :
141
+ """Get a task with the given name."""
142
+ if self .tasks :
143
+ return
144
+
145
+ warnings .warn (
146
+ "`self.tasks` is empty. Override `create_tasks` and create "
147
+ "`self.tasks` with the proper tasks."
148
+ )
149
+
139
150
@public
140
151
def get_task (self , name : str ) -> Optional [Task ]:
141
152
"""Get a task with the given name."""
@@ -144,13 +155,20 @@ def get_task(self, name: str) -> Optional[Task]:
144
155
@public
145
156
def start (self ) -> None :
146
157
"""Start tasks."""
158
+ if not self .tasks :
159
+ self .create_tasks ()
160
+
147
161
for task_name , task in self .tasks .items ():
148
162
print (f"Task `{ task_name } ` is starting ..." )
149
163
task .start ()
150
164
151
165
@public
152
166
def stop (self ) -> None :
153
167
"""Stop tasks."""
168
+ if not self .tasks :
169
+ warnings .warn ("There is no tasks to be stopped." )
170
+ return
171
+
154
172
for task_name , task in self .tasks .items ():
155
173
print (f"Task `{ task_name } ` is stopping ..." )
156
174
task .stop ()
You can’t perform that action at this time.
0 commit comments