<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _flush(self):
 """ Returns a list of all current data """

        if self._recording:
            raise Exception("Cannot flush data queue while recording!")
        if self._saving_cache:
            logging.warn("Flush when using cache means unsaved data will be lost and not returned!")
            self._cmds_q.put(("reset_data_segment",))
        else:
            data = self._extract_q(0)
            return data