parameters: (self, args, kwargs, shelving=False)
return_statement: return (out, args_id, metadata)
docstring: Call wrapped function and cache result, or read cache if available.
  
          This function returns the wrapped function output and some metadata.
  
          Arguments:
          ----------
  
          args, kwargs: list and dict
              input arguments for wrapped function
  
          shelving: bool
              True when called via the call_and_shelve function.
  
  
          Returns
          -------
          output: value or tuple or None
              Output of the wrapped function.
              If shelving is True and the call has been already cached,
              output is None.
  
          argument_hash: string
              Hash of function arguments.
  
          metadata: dict
              Some metadata about wrapped function call (see _persist_input()).
docstring_summary: Call wrapped function and cache result, or read cache if available.
docstring_tokens: Call wrapped function and cache result or read cache if available .
function: def _cached_call(self, args, kwargs, shelving=False):
          """Call wrapped function and cache result, or read cache if available.
  
          This function returns the wrapped function output and some metadata.
  
          Arguments:
          ----------
  
          args, kwargs: list and dict
              input arguments for wrapped function
  
          shelving: bool
              True when called via the call_and_shelve function.
  
  
          Returns
          -------
          output: value or tuple or None
              Output of the wrapped function.
              If shelving is True and the call has been already cached,
              output is None.
  
          argument_hash: string
              Hash of function arguments.
  
          metadata: dict
              Some metadata about wrapped function call (see _persist_input()).
          """
          func_id, args_id = self._get_output_identifiers(*args, **kwargs)
          metadata = None
          msg = None
  
          # Wether or not the memorized function must be called
          must_call = False
  
          # FIXME: The statements below should be try/excepted
          # Compare the function code with the previous to see if the
          # function code has changed
          if not (self._check_previous_func_code(stacklevel=4) and
                  self.store_backend.contains_item([func_id, args_id])):
              if self._verbose > 10:
                  _, name = get_func_name(self.func)
                  self.warn('Computing func {0}, argument hash {1} '
                            'in location {2}'
                            .format(name, args_id,
                                    self.store_backend.
                                    get_cached_func_info([func_id])['location']))
              must_call = True
          else:
              try:
                  t0 = time.time()
                  if self._verbose:
                      msg = _format_load_msg(func_id, args_id,
                                             timestamp=self.timestamp,
                                             metadata=metadata)
  
                  if not shelving:
                      # When shelving, we do not need to load the output
                      out = self.store_backend.load_item(
                          [func_id, args_id],
                          msg=msg,
                          verbose=self._verbose)
                  else:
                      out = None
  
                  if self._verbose > 4:
                      t = time.time() - t0
                      _, name = get_func_name(self.func)
                      msg = '%s cache loaded - %s' % (name, format_time(t))
                      print(max(0, (80 - len(msg))) * '_' + msg)
              except Exception:
                  # XXX: Should use an exception logger
                  _, signature = format_signature(self.func, *args, **kwargs)
                  self.warn('Exception while loading results for '
                            '{}\n {}'.format(signature, traceback.format_exc()))
  
                  must_call = True
  
          if must_call:
              out, metadata = self.call(*args, **kwargs)
              if self.mmap_mode is not None:
                  # Memmap the output at the first call to be consistent with
                  # later calls
                  if self._verbose:
                      msg = _format_load_msg(func_id, args_id,
                                             timestamp=self.timestamp,
                                             metadata=metadata)
                  out = self.store_backend.load_item([func_id, args_id], msg=msg,
                                                     verbose=self._verbose)
  
          return (out, args_id, metadata)
function_tokens: def _cached_call ( self , args , kwargs , shelving = False ) : func_id , args_id = self . _get_output_identifiers ( * args , * * kwargs ) metadata = None msg = None # Wether or not the memorized function must be called must_call = False # FIXME: The statements below should be try/excepted # Compare the function code with the previous to see if the # function code has changed if not ( self . _check_previous_func_code ( stacklevel = 4 ) and self . store_backend . contains_item ( [ func_id , args_id ] ) ) : if self . _verbose > 10 : _ , name = get_func_name ( self . func ) self . warn ( 'Computing func {0}, argument hash {1} ' 'in location {2}' . format ( name , args_id , self . store_backend . get_cached_func_info ( [ func_id ] ) [ 'location' ] ) ) must_call = True else : try : t0 = time . time ( ) if self . _verbose : msg = _format_load_msg ( func_id , args_id , timestamp = self . timestamp , metadata = metadata ) if not shelving : # When shelving, we do not need to load the output out = self . store_backend . load_item ( [ func_id , args_id ] , msg = msg , verbose = self . _verbose ) else : out = None if self . _verbose > 4 : t = time . time ( ) - t0 _ , name = get_func_name ( self . func ) msg = '%s cache loaded - %s' % ( name , format_time ( t ) ) print ( max ( 0 , ( 80 - len ( msg ) ) ) * '_' + msg ) except Exception : # XXX: Should use an exception logger _ , signature = format_signature ( self . func , * args , * * kwargs ) self . warn ( 'Exception while loading results for ' '{}\n {}' . format ( signature , traceback . format_exc ( ) ) ) must_call = True if must_call : out , metadata = self . call ( * args , * * kwargs ) if self . mmap_mode is not None : # Memmap the output at the first call to be consistent with # later calls if self . _verbose : msg = _format_load_msg ( func_id , args_id , timestamp = self . timestamp , metadata = metadata ) out = self . store_backend . load_item ( [ func_id , args_id ] , msg = msg , verbose = self . _verbose ) return ( out , args_id , metadata )