-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Cleanup ThreadPool with atexit rather than __del__ #1073
Conversation
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 PR also allows the client to be used as a context manager, which will automatically clean up after itself rather than having to wait til process exit. This fixes issue kubernetes-client#1037, where the API client could hang indefinitely at garbage collection.
9a5138a
to
18d21df
Compare
could you add a test that can run successfully with this fix, and would fail without the fix? |
/test |
c27391e
to
13dffb8
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabianvf, roycaihw The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Cleanup ThreadPool with atexit rather than __del__ (cherry picked from commit 0976d59)
Cleanup ThreadPool with atexit rather than __del__ (cherry picked from commit 0976d59)
Cleanup ThreadPool with atexit rather than __del__ (cherry picked from commit 0976d59)
cherry-pick of #1073 to release-11.0: Fix python3 hang
cherry-pick of #1073 to release-12.0: Fix python3 hang
cherry-pick of #1073 to release-10.0: Fix python3 hang
The implementation and tests were already picked up by the upstream OpenAPI generator [here](OpenAPITools/openapi-generator#5094). Patching in the tests here for correctness and clarity. Reference: kubernetes-client#1073 Signed-off-by: Nabarun Pal <[email protected]>
The implementation and tests were already picked up by the upstream OpenAPI generator [here](OpenAPITools/openapi-generator#5094). Patching in the tests here for correctness and clarity. Reference: kubernetes-client#1073 Signed-off-by: Nabarun Pal <[email protected]>
The implementation and tests were already picked up by the upstream OpenAPI generator [here](OpenAPITools/openapi-generator#5094). Patching in the tests here for correctness and clarity. Reference: kubernetes-client#1073 Signed-off-by: Nabarun Pal <[email protected]>
The implementation and tests were already picked up by the upstream OpenAPI generator [here](OpenAPITools/openapi-generator#5094). Patching in the tests here for correctness and clarity. Reference: kubernetes-client#1073 Signed-off-by: Nabarun Pal <[email protected]>
The implementation and tests were already picked up by the upstream OpenAPI generator [here](OpenAPITools/openapi-generator#5094). Patching in the tests here for correctness and clarity. Reference: kubernetes-client/python#1073 Signed-off-by: Nabarun Pal <[email protected]>
This removes the
__del__
function from the generated Python client,and replaces it with a
cleanup
function. When aThreadPool
is created,the
cleanup
function is registered with theatexit
module.This PR also allows the client to be used as a context manager, which
will automatically clean up after itself rather than having to wait til
process exit.
This fixes #1037, where the API client could hang indefinitely at
garbage collection.