Revision 7beb1e53
b/lib/jqueue.py | ||
---|---|---|
1090 | 1090 |
@param job_id: the job ID for the new job |
1091 | 1091 |
@type ops: list |
1092 | 1092 |
@param ops: The list of OpCodes that will become the new job. |
1093 |
@rtype: job ID |
|
1094 |
@return: the job ID of the newly created job |
|
1095 |
@raise errors.JobQueueDrainError: if the job is marked for draining |
|
1093 |
@rtype: L{_QueuedJob} |
|
1094 |
@return: the job object to be queued |
|
1095 |
@raise errors.JobQueueDrainError: if the job queue is marked for draining |
|
1096 |
@raise errors.JobQueueFull: if the job queue has too many jobs in it |
|
1096 | 1097 |
|
1097 | 1098 |
""" |
1098 | 1099 |
# Ok when sharing the big job queue lock, as the drain file is created when |
... | ... | |
1113 | 1114 |
logging.debug("Adding new job %s to the cache", job_id) |
1114 | 1115 |
self._memcache[job_id] = job |
1115 | 1116 |
|
1116 |
# Add to worker pool |
|
1117 |
self._wpool.AddTask(job) |
|
1118 |
|
|
1119 |
return job.id |
|
1117 |
return job |
|
1120 | 1118 |
|
1121 | 1119 |
@utils.LockedMethod |
1122 | 1120 |
@_RequireOpenQueue |
... | ... | |
1127 | 1125 |
|
1128 | 1126 |
""" |
1129 | 1127 |
job_id = self._NewSerialsUnlocked(1)[0] |
1130 |
return self._SubmitJobUnlocked(job_id, ops) |
|
1128 |
self._wpool.AddTask(self._SubmitJobUnlocked(job_id, ops)) |
|
1129 |
return job_id |
|
1131 | 1130 |
|
1132 | 1131 |
@utils.LockedMethod |
1133 | 1132 |
@_RequireOpenQueue |
... | ... | |
1138 | 1137 |
|
1139 | 1138 |
""" |
1140 | 1139 |
results = [] |
1140 |
tasks = [] |
|
1141 | 1141 |
all_job_ids = self._NewSerialsUnlocked(len(jobs)) |
1142 | 1142 |
for job_id, ops in zip(all_job_ids, jobs): |
1143 | 1143 |
try: |
1144 |
data = self._SubmitJobUnlocked(job_id, ops)
|
|
1144 |
tasks.append((self._SubmitJobUnlocked(job_id, ops), ))
|
|
1145 | 1145 |
status = True |
1146 |
data = job_id |
|
1146 | 1147 |
except errors.GenericError, err: |
1147 | 1148 |
data = str(err) |
1148 | 1149 |
status = False |
1149 | 1150 |
results.append((status, data)) |
1151 |
self._wpool.AddManyTasks(tasks) |
|
1150 | 1152 |
|
1151 | 1153 |
return results |
1152 | 1154 |
|
Also available in: Unified diff