Add job before returning any response (#1672)

This commit is contained in:
Pascal Bourgault
2024-06-10 08:32:17 -04:00
committed by GitHub
parent e32ac85eeb
commit eb321aa276
+17 -19
View File
@@ -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(