8 """Threadsafe wrapper for API object. This stores and returns a different api
9 object per thread, because httplib2 which underlies apiclient is not
13 def __init__(self, apiconfig=None, keep_params={}):
15 apiconfig = config.settings()
16 self.apiconfig = copy.copy(apiconfig)
17 self.local = threading.local()
18 self.keep = keep.KeepClient(api_client=self, **keep_params)
21 if 'api' not in self.local.__dict__:
22 self.local.api = api.api('v1', False, apiconfig=self.apiconfig)
25 def __getattr__(self, name):
26 # Proxy nonexistent attributes to the thread-local API client.
27 if name == "api_token":
28 return self.apiconfig['ARVADOS_API_TOKEN']
30 return getattr(self.localapi(), name)
31 except AttributeError:
32 return super(SafeApi, self).__getattr__(name)