Fix dropped receive during ThreadManager._spawn_jobs.
authorW. Trevor King <wking@drexel.edu>
Thu, 21 Oct 2010 01:29:25 +0000 (18:29 -0700)
committerW. Trevor King <wking@drexel.edu>
Thu, 21 Oct 2010 01:29:25 +0000 (18:29 -0700)
pysawsim/manager/__init__.py
pysawsim/manager/thread.py

index 0e01ac6f3aa00dd4f951809bd9d835bc68649253..71d591c87f78252ddf73f679fef568bdd09eed83 100644 (file)
@@ -205,13 +205,16 @@ class JobManager (object):
                 jobs[id] = self._jobs.pop(id)
         while len(ids) > 0:  # wait for outstanding jobs
             job = self._receive_job()
-            log().debug('receive job %s (%s)' % (job, job.status))
-            job.copy_onto(self._jobs[job.id])
+            self._handle_received_job(job)
             if job.id in ids and job.id in self._jobs:
                 jobs[job.id] = self._jobs.pop(job.id)
                 ids.remove(job.id)
         return jobs
 
+    def _handle_received_job(self, job):
+        log().debug('receive job %s (%s)' % (job, job.status))
+        job.copy_onto(self._jobs[job.id])
+
     def _receive_job(self):
         raise NotImplementedError
 
index 636545b1f9e5b285618e8281d3994b4419b1a763..5eb0edcfc0b904726b98bd6121dfdde271ba975f 100644 (file)
@@ -124,7 +124,9 @@ class ThreadManager (JobManager):
         return False
 
     def _spawn_job(self, job):
-        self._receive_job(block=False)
+        j = self._receive_job(block=False)
+        if j != None:
+            self._handle_received_job(j)
         if self._job_is_blocked(job):
             log().debug('block job %s' % job)
             self._blocked.append(job)