-
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] Cleanup ThreadPool with atexit rather than __del__ #10002
base: master
Are you sure you want to change the base?
Conversation
71ce8ed
to
7f7b8a5
Compare
@gaborbernat that might be the fastest review I've ever gotten, got it in while I was writing up the PR description. I think I addressed your comments |
I feel like maybe instead cleanup should be close and we should now also allow to call the client with the with statement, so it may cleanup automatically whenever the user no longer needs it. |
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.
05bd193
to
9a52e39
Compare
@gaborbernat renamed cleanup to close, think making it a context manager might be a bit out of scope for this bugfix but I can make a followup PR for it |
Hello, has this been merged and available in the latest codegen packages? I tried a few things with codegen versions but I still dont see this change in the api_client.py generated files.
|
Nope, we've moved on to use OpenAPITools/openapi-generator#5094 instead, that contains the fix. Swagger never addressed this issue. |
Thx much |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.Description of the PR
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 #9991, where the API client could hang indefinitely at
garbage collection.
cc @kenjones-cisco