Add job before returning any response (#1672)
This commit is contained in:
@@ -238,25 +238,6 @@ class BaseManager:
|
||||
|
||||
:returns: tuple of MIME type, response payload and status
|
||||
"""
|
||||
|
||||
process_id = p.metadata['id']
|
||||
current_status = JobStatus.accepted
|
||||
|
||||
job_metadata = {
|
||||
'type': 'process',
|
||||
'identifier': job_id,
|
||||
'process_id': process_id,
|
||||
'job_start_datetime': datetime.utcnow().strftime(
|
||||
DATETIME_FORMAT),
|
||||
'job_end_datetime': None,
|
||||
'status': current_status.value,
|
||||
'location': None,
|
||||
'mimetype': 'application/octet-stream',
|
||||
'message': 'Job accepted and ready for execution',
|
||||
'progress': 5
|
||||
}
|
||||
|
||||
self.add_job(job_metadata)
|
||||
self._send_in_progress_notification(subscriber)
|
||||
|
||||
try:
|
||||
@@ -406,6 +387,23 @@ class BaseManager:
|
||||
LOGGER.debug('Synchronous execution')
|
||||
handler = self._execute_handler_sync
|
||||
response_headers = None
|
||||
|
||||
# Add Job before returning any response.
|
||||
current_status = JobStatus.accepted
|
||||
job_metadata = {
|
||||
'type': 'process',
|
||||
'identifier': job_id,
|
||||
'process_id': process_id,
|
||||
'job_start_datetime': datetime.utcnow().strftime(DATETIME_FORMAT),
|
||||
'job_end_datetime': None,
|
||||
'status': current_status.value,
|
||||
'location': None,
|
||||
'mimetype': 'application/octet-stream',
|
||||
'message': 'Job accepted and ready for execution',
|
||||
'progress': 5
|
||||
}
|
||||
self.add_job(job_metadata)
|
||||
|
||||
# TODO: handler's response could also be allowed to include more HTTP
|
||||
# headers
|
||||
mime_type, outputs, status = handler(
|
||||
|
||||
Reference in New Issue
Block a user