Apply hotfixes
This commit is contained in:
parent
c206745dcd
commit
739665e677
@ -1991,7 +1991,7 @@ class CustomObjectsApi(object):
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
|
||||
['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501
|
||||
['application/merge-patch+json']) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['BearerToken'] # noqa: E501
|
||||
@ -2123,7 +2123,7 @@ class CustomObjectsApi(object):
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
|
||||
['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501
|
||||
['application/merge-patch+json']) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['BearerToken'] # noqa: E501
|
||||
@ -2255,7 +2255,7 @@ class CustomObjectsApi(object):
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
|
||||
['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501
|
||||
['application/merge-patch+json']) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['BearerToken'] # noqa: E501
|
||||
@ -2395,7 +2395,7 @@ class CustomObjectsApi(object):
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
|
||||
['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501
|
||||
['application/merge-patch+json']) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['BearerToken'] # noqa: E501
|
||||
@ -2535,7 +2535,7 @@ class CustomObjectsApi(object):
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
|
||||
['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501
|
||||
['application/merge-patch+json']) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['BearerToken'] # noqa: E501
|
||||
@ -2675,7 +2675,7 @@ class CustomObjectsApi(object):
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
|
||||
['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501
|
||||
['application/merge-patch+json']) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['BearerToken'] # noqa: E501
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
import json
|
||||
import mimetypes
|
||||
@ -77,11 +78,19 @@ class ApiClient(object):
|
||||
# Set default User-Agent.
|
||||
self.user_agent = 'OpenAPI-Generator/12.0.0-snapshot/python'
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@ -89,6 +98,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
13
kubernetes/client/apis/__init__.py
Normal file
13
kubernetes/client/apis/__init__.py
Normal file
@ -0,0 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
import warnings
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
# alias kubernetes.client.api package and print deprecation warning
|
||||
from kubernetes.client.api import *
|
||||
|
||||
warnings.filterwarnings('default', module='kubernetes.client.apis')
|
||||
warnings.warn(
|
||||
"The package kubernetes.client.apis is renamed and deprecated, use kubernetes.client.api instead (please note that the trailing s was removed).",
|
||||
DeprecationWarning
|
||||
)
|
||||
25
kubernetes/test/test_api_client.py
Normal file
25
kubernetes/test/test_api_client.py
Normal file
@ -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)
|
||||
Loading…
Reference in New Issue
Block a user