'Given a function, a SQL string, a tuple, and a function, return ???.'

def _do_query(self, fetchfunc, query, params, process):

    key = (query, params)
    self.locks.checkout.acquire()
    try:
        if (key in self.cache):
            entry = self.cache[key]
            entry.lock.acquire()
            entry = self.cache[key]
        else:
            dummy = Entry()
            dummy.lock.acquire()
            self.locks.checkin.acquire()
            try:
                if (key in self.cache):
                    entry = self.cache[key]
                else:
                    self.cache[key] = dummy
                    entry = dummy
            finally:
                self.locks.checkin.release()
    finally:
        self.locks.checkout.release()
    try:
        if ((time.time() - entry.timestamp) < self.threshold):
            if (entry.exc is not None):
                raise entry.exc
            return entry.result
        else:
            try:
                entry.result = fetchfunc(query, params)
                if (process is not None):
                    entry.result = process(entry.result)
                entry.exc = None
            except:
                entry.result = None
                entry.exc = (FormattingError(traceback.format_exc()), sys.exc_info()[2])
        self.locks.checkin.acquire()
        try:
            entry.timestamp = time.time()
            self.cache[key] = entry
            if (entry.exc is not None):
                raise entry.exc[0]
            else:
                return entry.result
        finally:
            self.locks.checkin.release()
    finally:
        entry.lock.release()
