You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
This removes the `__del__` function from the generated Python client,
and replaces it with a `cleanup` function. When a ThreadPool is created,
the cleanup function is registered with the `atexit` module.
This fixesOpenAPITools#5093, where the API client could hang indefinitely at
garbage collection.
* [python] Cleanup ThreadPool with atexit rather than __del__
This removes the `__del__` function from the generated Python client,
and replaces it with a `cleanup` function. When a ThreadPool is created,
the cleanup function is registered with the `atexit` module.
This fixes#5093, where the API client could hang indefinitely at
garbage collection.
* Update petstore examples
* Test to ensure threadpool is cleaned up
* Docs now encourage using the context manager
* Regenerate docs
* Update samples
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:
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
The text was updated successfully, but these errors were encountered: