Skip to content

[Python] Generated code is out of contract - application hangs indefinitely  #5093

@fabianvf

Description

@fabianvf

Bug originally reported by @gaborbernat in the swagger-codegen project, but the same issue applies here: swagger-api/swagger-codegen#9991

The generated code snippet from - https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python/api_client.mustache#L78 is not allowed:

def __del__(self):
    if self._pool is not None:
        self._pool.close()
        self._pool.join()

The very simple program of creating a global client, and then just exiting will hang indefinitely on Python3.8. Initially raised as CPython bug under https://bugs.python.org/issue39360, but @pablogsal (core CPython developer) investigated and concluded that this way of cleaning up pools is not supported. Instead one should either allow the user to close or if the user did not do the generated code should do by registering https://docs.python.org/3.8/library/atexit.html callbacks.

Fix incoming

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions