Python openapi-generator how to make http asyncrhonous calls

by Joan Pascual Sana   Last Updated August 14, 2019 00:26 AM

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.

By the way, on the generated python code is wrote on the call functions:

"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.rs_gxs_channels_turtle_search_request(async_req=True)
>>> result = thread.get()
"""

So it seems that support in some way async calls.

But is not defined how to work with, for example if I call the thread:

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" phrase is never printed until the connection is closed by the server, so is not async, so is not a separated thread.

So I expect a way to set a callback and to reproduce the call in async way.



Related Questions


OpenAPI and CLI generators tools for server stubs

Updated September 27, 2018 00:26 AM