From c5d5cda7a49eec2f400c0a4160ecc3d1e09c521a Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Thu, 6 Jun 2024 09:58:00 -0700 Subject: [PATCH] Cherry pick lazy pool init from swagger-codegen It appears that very new Python versions are triggering a trackback in self.pool.close() for the __del__ method of the ApiClient class. Since the OneFS API doesn't use the async methods, this change should avoid the problem. --- isilon_sdk/isilon_sdk/v9_0_0/api_client.py | 13 ++++++++++--- isilon_sdk/isilon_sdk/v9_1_0/api_client.py | 13 ++++++++++--- isilon_sdk/isilon_sdk/v9_2_0/api_client.py | 13 ++++++++++--- isilon_sdk/isilon_sdk/v9_2_1/api_client.py | 13 ++++++++++--- isilon_sdk/isilon_sdk/v9_3_0/api_client.py | 13 ++++++++++--- isilon_sdk/isilon_sdk/v9_4_0/api_client.py | 13 ++++++++++--- isilon_sdk/isilon_sdk/v9_5_0/api_client.py | 13 ++++++++++--- 7 files changed, 70 insertions(+), 21 deletions(-) diff --git a/isilon_sdk/isilon_sdk/v9_0_0/api_client.py b/isilon_sdk/isilon_sdk/v9_0_0/api_client.py index 281a5f84..4e224b43 100644 --- a/isilon_sdk/isilon_sdk/v9_0_0/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_0_0/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self): diff --git a/isilon_sdk/isilon_sdk/v9_1_0/api_client.py b/isilon_sdk/isilon_sdk/v9_1_0/api_client.py index 30876681..44116b15 100644 --- a/isilon_sdk/isilon_sdk/v9_1_0/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_1_0/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self): diff --git a/isilon_sdk/isilon_sdk/v9_2_0/api_client.py b/isilon_sdk/isilon_sdk/v9_2_0/api_client.py index 5773e5c7..fd24831e 100644 --- a/isilon_sdk/isilon_sdk/v9_2_0/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_2_0/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self): diff --git a/isilon_sdk/isilon_sdk/v9_2_1/api_client.py b/isilon_sdk/isilon_sdk/v9_2_1/api_client.py index 01d582d5..57f2fd60 100644 --- a/isilon_sdk/isilon_sdk/v9_2_1/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_2_1/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self): diff --git a/isilon_sdk/isilon_sdk/v9_3_0/api_client.py b/isilon_sdk/isilon_sdk/v9_3_0/api_client.py index 0a53e86e..9ac9a74b 100644 --- a/isilon_sdk/isilon_sdk/v9_3_0/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_3_0/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self): diff --git a/isilon_sdk/isilon_sdk/v9_4_0/api_client.py b/isilon_sdk/isilon_sdk/v9_4_0/api_client.py index efc94d9d..a57765ce 100644 --- a/isilon_sdk/isilon_sdk/v9_4_0/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_4_0/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self): diff --git a/isilon_sdk/isilon_sdk/v9_5_0/api_client.py b/isilon_sdk/isilon_sdk/v9_5_0/api_client.py index 35b9a09c..81d72f01 100644 --- a/isilon_sdk/isilon_sdk/v9_5_0/api_client.py +++ b/isilon_sdk/isilon_sdk/v9_5_0/api_client.py @@ -67,7 +67,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, configuration = Configuration() self.configuration = configuration - self.pool = ThreadPool() + self._pool = None # Use the pool property to lazily initialize the ThreadPool. self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -86,8 +86,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.x_csrf_token = None def __del__(self): - self.pool.close() - self.pool.join() + if self._pool is not None: + self._pool.close() + self._pool.join() + + @property + def pool(self): + if self._pool is None: + self._pool = ThreadPool() + return self._pool @property def user_agent(self):