From 3d50e0598e1e43671ff8e22f58fd0d7986059e96 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 27 Jun 2019 17:05:25 -0700 Subject: [PATCH] cutter: Handle case where we are told to stop while looking for candidates Previously, it would return None and things would break. Now the None is handled correctly, and is documented. --- cutter/cutter/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 8fe62fd..e07fa31 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -85,6 +85,9 @@ class Cutter(object): # any unhandled errors will cause the process to restart and clean up as per rollback_all_owned(). while not self.stop.is_set(): job = self.find_candidate() + if not job: + # find_candidate() returning None means we're stopping + continue try: self.claim_job(job) except CandidateGone: @@ -99,7 +102,7 @@ class Cutter(object): def find_candidate(self): """List EDITED events and find one at random which we have all segments for (or for which allow_holes is true), returning a CutJob. - Polls until one is available. + Polls until one is available, or we are stopping (in which case it returns None) """ while not self.stop.is_set(): try: