@@ -143,6 +143,7 @@ class DataPrinterManager(ProcessManagerCore):
143143 output_queue_count = 1 ,
144144 dynamic_up_scaling = dynamic_scaling ,
145145 dynamic_down_scaling = dynamic_scaling ,
146+ spread_stop_signal = True ,
146147 )
147148 # Configure the manager to generate 1 worker/process.
148149 data_printer_manager = DataPrinterManager (
@@ -164,18 +165,12 @@ class DataPrinterManager(ProcessManagerCore):
164165 print ("Controller pushed:" , data )
165166 data_filter_manager .push_to_input_queue (data )
166167
167- # Push the stop signal at the end of the input queue to stop the workers.
168- # Note:
169- # As the data printer is a dependency of the data filter, we don't need to
170- # stop it explicitly. It will be stopped automatically when the data filter
171- # manager stops.
168+ # If terminate the manager and all the managed workers after waiting for the
169+ # workers to finish processing the data.
172170 #
173- data_filter_manager .push_stop_signal ()
174- # Wait for the manager to finish processing the data.
175- data_filter_manager .wait ()
176-
177- # If we want to terminate the manager and all workers, we can call the
178- # terminate method.
179- data_filter_manager .terminate ()
171+ # Note: In soft mode, the manager will wait for the workers to finish processing
172+ # the data before terminating them. In hard mode, the manager will terminate the
173+ # workers immediately.
174+ data_filter_manager .terminate (mode = "soft" )
180175
181176 print ("Data filtered successfully." )
0 commit comments