Commit 73bac910 authored by Manuel Günther's avatar Manuel Günther

Now the local scheduler is writing the results of the finished jobs.

parent 8a831aa0
......@@ -159,7 +159,6 @@ class JobManagerLocal(JobManager):
# keep the scheduler alive until every job is finished or the KeyboardInterrupt is caught
while True:
# Flag that might be set in some rare cases, and that prevents the scheduler to die
repeat_execution = False
# FIRST, try if there are finished processes; this does not need a lock
......@@ -171,11 +170,14 @@ class JobManagerLocal(JobManager):
# process ended
job_id = task[1]
array_id = task[2] if len(task) > 2 else None
logger.info("Job '%s' finished execution" % self._format_log(job_id, array_id))
self.lock()
job, array_job = self._job_and_array(job_id, array_id)
if array_job: job = array_job
result = "%s (%d)" % (job.status, job.result)
self.unlock()
logger.info("Job '%s' finished execution with result %s" % (self._format_log(job_id, array_id), result))
# in any case, remove the job from the list
del running_tasks[task_index]
# SECOND, check if new jobs can be submitted; THIS NEEDS TO LOCK THE DATABASE
if len(running_tasks) < parallel_jobs:
# get all unfinished jobs:
......
......@@ -43,7 +43,7 @@ class JobManager:
raise RuntimeError('Dead lock detected. Please do not try to lock the session when it is already locked!')
if sqlalchemy_version < [0,7,8]:
# for old sqlalchemy versions, in some cases it is required to re-generate the enging for each session
# for old sqlalchemy versions, in some cases it is required to re-generate the engine for each session
self._engine = sqlalchemy.create_engine("sqlite:///"+self._database)
self._session_maker = sqlalchemy.orm.sessionmaker(bind=self._engine)
......@@ -160,6 +160,7 @@ class JobManager:
if not len(jobs):
# it seems that the job has been deleted in the meanwhile
logger.error("The job with id '%d' could not be found in the database!" % job_id)
self.unlock()
return
job = jobs[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment