Skip to content

Commit

Permalink
Merge pull request #179 from olegy-ait/fix/multiprocessing
Browse files Browse the repository at this point in the history
Handle multiprocessing.pool.ThreadPool init on OS without shared memory for processes
  • Loading branch information
jv-asana committed Aug 17, 2023
2 parents acbdad0 + 4bef192 commit c40cedd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions codegen/templates/api_client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{>partial_header}}
from __future__ import absolute_import

import logging
import datetime
import json
import mimetypes
Expand Down Expand Up @@ -63,7 +64,10 @@ class ApiClient(object):
configuration = Configuration()
self.configuration = configuration

self.pool = ThreadPool()
try:
self.pool = ThreadPool()
except OSError:
logging.warning('Looks like your system does not support ThreadPool but it will try without it if you do not use async requests')
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
Expand All @@ -83,8 +87,9 @@ class ApiClient(object):
)

def __del__(self):
self.pool.close()
self.pool.join()
if hasattr(self, "pool"):
self.pool.close()
self.pool.join()

@property
def user_agent(self):
Expand Down

0 comments on commit c40cedd

Please sign in to comment.