forked from fspv/python-leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_thread_pool.patch
More file actions
29 lines (25 loc) · 825 Bytes
/
Copy pathfix_thread_pool.patch
File metadata and controls
29 lines (25 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/leetcode/api_client.py b/leetcode/api_client.py
index 8b27247..8092ae5 100644
--- a/leetcode/api_client.py
+++ b/leetcode/api_client.py
@@ -10,6 +10,7 @@
"""
from __future__ import absolute_import
+import atexit
import datetime
import json
import mimetypes
@@ -66,6 +67,7 @@ class ApiClient(object):
self.configuration = configuration
self.pool = ThreadPool()
+ atexit.register(self._close_pool)
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
@@ -74,7 +76,7 @@ class ApiClient(object):
# Set default User-Agent.
self.user_agent = 'Swagger-Codegen/1.0.0/python'
- def __del__(self):
+ def _close_pool(self):
self.pool.close()
self.pool.join()