[Python] How to make http asyncrhonous calls with generated python client
Created by: jpascualsana
Description
I'm creating a auto-generated API client using the openapi-generator for python. This API has some asynchronous functions that returns lines of data: JSON
asynchronously.
I would like to have a callback that get this data and process it on a separate thread but I don't know how to use the async=True
option when the call is instantiated. As I show it return a Thread
but I don't know how to set the callback for it.
openapi-generator version
➜ openapi-generator version
4.0.3
OpenAPI declaration file content or url
https://gitlab.com/snippets/1882068/raw
Note: this YAML is auto generated from a Doxygen documentation for RetroShare project using this
Command line used for generation
openapi-generator generate -i wrapper_openapi.yml -g python -o ../openapi-python-retroshare-api-wrapper
Steps to reproduce
You can generate the wrapper using the command above with the provided YAML or cloning this.
I tested this code:
thread = api_instance.rs_gxs_channels_turtle_search_request(async_req=True, req_rs_gxs_channels_turtle_search_request=req_rs_gxs_channels_turtle_search_request)
result = thread.get()
print("should be printed")
The program just stop, the "should be printed" string is never printed until the connection is closed by the server, so is not async, so is not a separated thread or I don't know how to use it.
In addition I would like that the responses received asynchronously be processed in a callback function
Related issues/PRs
I just opened an stackoverflow question: