7 """Threadsafe wrapper for API object. This stores and returns a different api
8 object per thread, because httplib2 which underlies apiclient is not
12 def __init__(self, apiconfig=None, keep_params={}):
15 self.host = apiconfig.get('ARVADOS_API_HOST')
16 self.api_token = apiconfig.get('ARVADOS_API_TOKEN')
17 self.insecure = apiconfig.flag_is_true('ARVADOS_API_HOST_INSECURE')
18 self.local = threading.local()
19 self.keep = keep.KeepClient(api_client=self, **keep_params)
22 if 'api' not in self.local.__dict__:
23 self.local.api = api.api('v1', False, self.host,
24 self.api_token, self.insecure)
27 def __getattr__(self, name):
28 # Proxy nonexistent attributes to the thread-local API client.
30 return getattr(self.localapi(), name)
31 except AttributeError:
32 return super(SafeApi, self).__getattr__(name)