-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1078 from fabianvf/fix-py3-hang-11
cherry-pick of #1073 to release-11.0: Fix python3 hang
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# coding: utf-8 | ||
|
||
|
||
import atexit | ||
import weakref | ||
import unittest | ||
|
||
import kubernetes | ||
|
||
|
||
class TestApiClient(unittest.TestCase): | ||
|
||
def test_context_manager_closes_threadpool(self): | ||
with kubernetes.client.ApiClient() as client: | ||
self.assertIsNotNone(client.pool) | ||
pool_ref = weakref.ref(client._pool) | ||
self.assertIsNotNone(pool_ref()) | ||
self.assertIsNone(pool_ref()) | ||
|
||
def test_atexit_closes_threadpool(self): | ||
client = kubernetes.client.ApiClient() | ||
self.assertIsNotNone(client.pool) | ||
self.assertIsNotNone(client._pool) | ||
atexit._run_exitfuncs() | ||
self.assertIsNone(client._pool) |