-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] Generated code is out of contract - application hangs indefinitely #9991
Comments
To clarify: the reason is "not supported" is because the interpreter does not promise that
This worked on Python <3.7 in a very flaky way: the pool used a busy loop (now it uses a more robust system of sentinels) and the |
We're seeing indefinite hangs in the |
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 swagger-api#9991, where the API client could hang indefinitely at garbage collection.
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 swagger-api#9991, where the API client could hang indefinitely at garbage collection.
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 swagger-api#9991, where the API client could hang indefinitely at garbage collection.
Was this ever merged? |
@noamgat it was merged to the openapi repo, never here |
Is there any update on this issue? It hangs still, here's my code to check: from swagger_client import ApiClient, Configuration, UserApi
configuration = Configuration()
configuration.host = host
configuration.api_key['Authorization'] = token
configuration.api_key_prefix['Authorization']='Bearer'
client = UserApi(ApiClient(configuration))
for item in client.list_users():
print(item)
# and it can't exit the script, hangs indefinitely |
- See commit example fspv/python-leetcode@e9e93d8 - See discussion swagger-api/swagger-codegen#9991
The generated code snippet from - https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/python/api_client.mustache#L73 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.
The code in question seemed to be added within #6396 by @tuxbotix with approvers being @scottrw93 @taxpon @frol @mbohlool, so tagging them for context.
The text was updated successfully, but these errors were encountered: