Skip to content

Commit e721591

Browse files
committed
Fix TypeError in underlying API when self.pool is None for async requests.
1 parent 048e4b3 commit e721591

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

paapi5_python_sdk/api_client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,24 @@ def __init__(self,
8686
configuration = Configuration()
8787
self.configuration = configuration
8888

89-
self.pool = ThreadPool()
89+
self.pool = None
9090
self.rest_client = rest.RESTClientObject(configuration)
9191
self.default_headers = {}
9292
if header_name is not None:
9393
self.default_headers[header_name] = header_value
9494
self.cookie = cookie
9595
# Set default User-Agent.
9696
self.user_agent = 'paapi5-python-sdk/1.0.0'
97-
97+
9898
self.access_key = access_key
9999
self.secret_key = secret_key
100100
self.host = host
101101
self.region = region
102102

103103
def __del__(self):
104-
self.pool.close()
105-
self.pool.join()
104+
if self.pool is not None:
105+
self.pool.close()
106+
self.pool.join()
106107

107108
@property
108109
def user_agent(self):
@@ -349,6 +350,8 @@ def call_api(self, resource_path, method, api_name,
349350
_return_http_data_only, collection_formats,
350351
_preload_content, _request_timeout)
351352
else:
353+
if self.pool is None:
354+
self.pool = ThreadPool()
352355
thread = self.pool.apply_async(self.__call_api, (resource_path,
353356
method, api_name, path_params, query_params,
354357
header_params, body,

0 commit comments

Comments
 (0)