diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index 8f9655e..6cb37ae 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -339,6 +339,13 @@ class AutopkgtestPolicy(BasePolicy): return valid_version + def save_pending_json(self): + # update the pending tests on-disk cache + self.logger.info('Updating pending requested tests in %s' % self.pending_tests_file) + with open(self.pending_tests_file + '.new', 'w') as f: + json.dump(self.pending_tests, f, indent=2) + os.rename(self.pending_tests_file + '.new', self.pending_tests_file) + def save_state(self, britney): super().save_state(britney) @@ -352,11 +359,7 @@ class AutopkgtestPolicy(BasePolicy): json.dump(test_results, f, indent=2) os.rename(self.results_cache_file + '.new', self.results_cache_file) - # update the pending tests on-disk cache - self.logger.info('Updating pending requested tests in %s', self.pending_tests_file) - with open(self.pending_tests_file + '.new', 'w') as f: - json.dump(self.pending_tests, f, indent=2) - os.rename(self.pending_tests_file + '.new', self.pending_tests_file) + self.save_pending_json() def apply_src_policy_impl(self, tests_info, item, source_data_tdist, source_data_srcdist, excuse): # initialize @@ -1043,6 +1046,8 @@ class AutopkgtestPolicy(BasePolicy): arch_list.append(arch) arch_list.sort() self.send_test_request(src, arch, full_trigger, huge=huge) + # save pending.json right away, so that we don't re-request if britney crashes + self.save_pending_json() def result_in_baseline(self, src, arch): '''Get the result for src on arch in the baseline