Started seting the running flag immediately on the call to start()

instead of after all the startup tsks are done. This alleviates a potential
problem where start() could be called more than once in quick succession
with unpredictable results.
This commit is contained in:
Erik Thuning 2024-06-04 15:45:09 +02:00
parent 30361abdd9
commit 49d1da804b

@ -56,7 +56,11 @@ class Pipeline:
self.logger = logging.getLogger('play-daemon.pipeline')
def start(self):
if self.running:
raise Exception("Already running!")
self.running = True
self.logger.info('Starting')
for item in os.scandir(self.config['Pipeline']['tempdir']):
shutil.rmtree(item)
self.workthread = WorkThread(int(self.config['Pool']['capacity']))
@ -91,7 +95,6 @@ class Pipeline:
preprocessor.start()
self.watcher.start()
self.running = True
self.logger.debug('Started')
def stop(self):
@ -99,8 +102,6 @@ class Pipeline:
if not self.running:
raise Exception("Not running!")
self.running = False
self.watcher.shutdown()
for preprocessor in self.preprocessors.values():
preprocessor.shutdown()
@ -112,3 +113,4 @@ class Pipeline:
self.notifier.shutdown()
self.logger.debug('Stopped')
self.running = False