-
-
Notifications
You must be signed in to change notification settings - Fork 314
execute_process is not able to respond async if job output media type is different from application/json #2311
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
It is currently not possible to have a process that operates in async mode and generates an output with a media type that is not JSON.
As per this section of the execute_process API handler:
pygeoapi/pygeoapi/api/processes.py
Lines 523 to 540 in 08031d4
| if mime_type == 'application/json': | |
| if requested_response == 'document': | |
| pretty_print_ = api.pretty_print | |
| else: # raw | |
| pretty_print_ = False | |
| response2 = to_json(response, pretty_print_) | |
| else: | |
| response2 = response | |
| if (headers.get('Preference-Applied', '') == RequestedProcessExecutionMode.respond_async.value): # noqa | |
| LOGGER.debug('Asynchronous mode detected, returning statusInfo') | |
| response2 = { | |
| 'jobID': job_id, | |
| 'type': 'process', | |
| 'status': status.value | |
| } | |
| response2 = to_json(response2, pretty_print_) |
It can be observed that:
- When the
if mime_type == "application/json"condition isFalse(line 530), thepretty_print_variable is never created. - Regardless, this variable is accessed later (line 540) if the processor is executing in async mode. This causes this error:
File "/home/ricardo/dev/pygeoapi/pygeoapi/api/processes.py", line 540, in execute_process
response2 = to_json(response2, pretty_print_)
^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'pretty_print_' where it is not associated with a value@tomkralidis this seems to be a regression introduced in 0b53d49 like #2304
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working