From a1ab48daf7b572bf857b115898db2d947552a155 Mon Sep 17 00:00:00 2001 From: Valentin David Date: Tue, 22 Jan 2019 14:03:21 +0100 Subject: Fix crash when spawned job completes very fast Job can complete before we return from `Job.span()` to `Scheduler._spawn_job()`, so that `_active_jobs` would not yet contain the job. This would print a stack on the console and try to run a second time the job which can have unexpected effects. In order to reproduce the issue, in `buildstream/_scheduler/jobs/job.py`, in `Job.spawn`, add a call to `time.sleep()` right before call to `asyncio.get_child_watcher()`. This fixes issue #857. --- buildstream/_scheduler/scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py index f35a85b23..176900b33 100644 --- a/buildstream/_scheduler/scheduler.py +++ b/buildstream/_scheduler/scheduler.py @@ -314,10 +314,10 @@ class Scheduler(): # job (Job): The job to spawn # def _spawn_job(self, job): - job.spawn() self._active_jobs.append(job) if self._job_start_callback: self._job_start_callback(job) + job.spawn() # Callback for the cache size job def _cache_size_job_complete(self, status, cache_size): -- cgit v1.2.1