Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pygeoapi/api/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
# Copyright (c) 2024 Francesco Martinelli
# Copyright (c) 2026 Francesco Martinelli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -524,7 +524,7 @@ def execute_process(api: API, request: APIRequest,
else:
response2 = response

if execution_mode == RequestedProcessExecutionMode.respond_async:
if (headers.get('Preference-Applied', '') == RequestedProcessExecutionMode.respond_async.value): # noqa
LOGGER.debug('Asynchronous mode detected, returning statusInfo')
response2 = {
'jobID': job_id,
Expand Down
42 changes: 28 additions & 14 deletions pygeoapi/process/manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Copyright (c) 2024 Tom Kralidis
# (c) 2023 Ricardo Garcia Silva
# (c) 2024 Francesco Martinelli
# (c) 2026 Francesco Martinelli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -393,9 +393,10 @@ def execute_process(
'requested_response': requested_response
}

job_control_options = processor.metadata.get(
'jobControlOptions', [])

if execution_mode == RequestedProcessExecutionMode.respond_async:
job_control_options = processor.metadata.get(
'jobControlOptions', [])
# client wants async - do we support it?
process_supports_async = (
ProcessExecutionMode.async_execute.value in job_control_options
Expand All @@ -414,17 +415,30 @@ def execute_process(
'Preference-Applied': (
RequestedProcessExecutionMode.wait.value)
}
elif execution_mode == RequestedProcessExecutionMode.wait:
# client wants sync - pygeoapi implicitly supports sync mode
LOGGER.debug('Synchronous execution')
handler = self._execute_handler_sync
response_headers = {
'Preference-Applied': RequestedProcessExecutionMode.wait.value}
else: # client has no preference
# according to OAPI - Processes spec we ought to respond with sync
LOGGER.debug('Synchronous execution')
handler = self._execute_handler_sync
response_headers = None
else: # client has no preference or clients wants sync
# do we support sync?
process_supports_sync = (
ProcessExecutionMode.sync_execute.value in job_control_options
)
if not process_supports_sync:
LOGGER.debug('Asynchronous execution')
handler = self._execute_handler_async
response_headers = {
'Preference-Applied': (
RequestedProcessExecutionMode.respond_async.value)
}
else:
# according to OAPI - Processes spec we ought to
# respond with sync
LOGGER.debug('Synchronous execution')
handler = self._execute_handler_sync
if execution_mode == RequestedProcessExecutionMode.wait:
response_headers = None
else:
response_headers = {
'Preference-Applied': (
RequestedProcessExecutionMode.wait.value)
}

# Add Job before returning any response.
current_status = JobStatus.accepted
Expand Down