Esempio n. 1
0
 def _fetch_instance(self):
     """Fetch the underlying instance.
     """
     if not self._instance:
         # Try to find it in the cache
         self._instance = CLIENT_INSTANCE_CACHE.get(self._url, None)
     if not self._instance:
         # We now have a cache miss so construct a new connector
         self._instance = _InstanceConnector(
             self._url, **self._fields)
         if CLIENT_INSTANCE_CACHE.enabled:
             CLIENT_INSTANCE_CACHE[self._url] = self._instance
Esempio n. 2
0
 def _fetch_instance(self):
     """Fetch the underlying instance.
     """
     from slumber import _client
     for candidate in getattr(_client, '_instances', []):
         candidate_url = from_slumber_scheme(candidate._url)
         self_url = from_slumber_scheme(self._url)
         if candidate_url == self_url:
             return candidate
     instance = CLIENT_INSTANCE_CACHE.get(self._url, None)
     if not instance:
         # We now have a cache miss so construct a new connector
         instance = _InstanceConnector(self._url, **self._fields)
         if CLIENT_INSTANCE_CACHE.enabled:
             CLIENT_INSTANCE_CACHE[self._url] = instance
     return instance
Esempio n. 3
0
 def _flush_client_instance_cache(cls):
     """Flush the (global) instance cache.
     """
     CLIENT_INSTANCE_CACHE.clear()