Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3696
Closed
Open
Issue created Aug 19, 2019 by Administrator@rootContributor

[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:

https://stackoverflow.com/questions/57486784/python-openapi-generator-how-to-make-http-asyncrhonous-calls

Assignee
Assign to
Time tracking