Allow clean scheduler shutdown when priming fails

If config priming failed we need to unblock the main thread by setting
the primed event so we can join the main thread during shutdown.

So far this was only done after trying to join the main thread, so we
need to set the primed event earlier.

Change-Id: I5aef9a215cfd53baa94e525f8c303592a6c7e4b8
This commit is contained in:
Simon Westphahl 2022-11-30 11:52:39 +01:00
parent 5443a0f51b
commit 71598ee51b
No known key found for this signature in database
1 changed files with 3 additions and 2 deletions

View File

@ -369,6 +369,9 @@ class Scheduler(threading.Thread):
self.log.debug("Stopping scheduler")
self._stopped = True
self.wake_event.set()
# Main thread, connections and layout update may be waiting
# on the primed event
self.primed_event.set()
self.start_cleanup_thread.join()
self.log.debug("Stopping apscheduler")
self.apsched.shutdown()
@ -382,8 +385,6 @@ class Scheduler(threading.Thread):
self.log.debug("Stopping nodepool")
self.nodepool.stop()
self.log.debug("Stopping connections")
# Connections and layout update may be waiting on the primed event
self.primed_event.set()
# Layout update can reconfigure connections, so make sure
# layout update is stopped first.
self.log.debug("Waiting for layout update thread")