Quiesces the currently running ingest
760559
private void quiesceIngest() throws IOException {
    InjectionHandler.processEvent(InjectionEvent.STANDBY_QUIESCE_INGEST);
    synchronized (ingestStateLock) {
      assertState(StandbyIngestState.INGESTING_EDITS,
          StandbyIngestState.NOT_INGESTING);
      ingest.quiesce();
    }
    try {
      ingestThread.join();
      currentIngestState = StandbyIngestState.NOT_INGESTING;
      LOG.info("Standby: Quiesce - Ingest thread for segment: "
          + ingest.toString() + " exited.");
    } catch (InterruptedException e) {
      LOG.info("Standby: Quiesce - Ingest thread interrupted.");
      throw new IOException(e.getMessage());
    }
  }
634664
def _prepare_ingest(self):
        """"""

        # see also commentary on DigitalObject.DUMMY_URIREF
        self.replace_uri(self.obj.DUMMY_URIREF, self.obj.uriref)
1218609
private void preIngestIfNeeded(boolean firstRun,
                                   DOManager doManager,
                                   RDFName objectName) throws Exception {
        PID pid = new PID(objectName.uri.substring("info:fedora/".length()));
        boolean exists = doManager.objectExists(pid.toString());
        if (exists && firstRun) {
            logger.info("Purging old system object: {}", pid);
            Context context = ReadOnlyContext.getContext(null,
                                                         null,
                                                         null,
                                                         false);
            DOWriter w = doManager.getWriter(USE_DEFINITIVE_STORE,
                                             context,
                                             pid.toString());
            w.remove();
            try {
                w.commit("Purged by Fedora at startup (to be re-ingested)");
                exists = false;
            } finally {
                doManager.releaseWriter(w);
            }
        }
        if (!exists) {
            logger.info("Ingesting new system object: {}", pid);
            InputStream xml = getStream("org/fcrepo/server/resources/"
                                        + pid.toFilename() + ".xml");
            Context context = ReadOnlyContext.getContext(null,
                                                         null,
                                                         null,
                                                         false);
            DOWriter w = doManager.getIngestWriter(USE_DEFINITIVE_STORE,
                                                   context,
                                                   xml,
                                                   Constants.FOXML1_1.uri,
                                                   "UTF-8",
                                                   null);
            try {
                w.commit("Pre-ingested by Fedora at startup");
            } finally {
                doManager.releaseWriter(w);
            }
        }
    }
380258
def consume(self, limit=None):
        """"""
        for total_message_count in count():
            if limit and total_message_count >= limit:
                raise StopIteration

            if not self.channel.is_open:
                raise StopIteration

            self.channel.wait()
            yield True
1152401
def finish(self):
        
        super(InterruptibleMixin, self).finish()
        signal(SIGINT, self.original_handler)
500003
function flushQueueIfAvailable()
    {
        if (!isLogAvailable())
            return;

        clearInterval(WebInspector.log.interval);
        delete WebInspector.log.interval;

        flushQueue();
    }
753115
def _consume(self):
        
        while True:
            try:
                task, args, kwargs = self.queue.get(True)
                task(*args, **kwargs)
            finally:
                self.queue.task_done()
1207897
def run(self):
        """"""
        input = self._consume()
        put_item = self._que_out.put
        
        try:
            if input is None: # producer
                res = self._callable(*self._args, **self._kwargs)
            else:
                res = self._callable(input, *self._args, **self._kwargs)
            if res != None:
                for item in res:
                    put_item(item)

        except Exception as e:
            # we catch an error, we send on the error que, we consume the input and we exit
            # consuming the input queue avoid to keep running processes before exiting with
            # errors
            self._que_err.put((self.name, e))
            if input is not None:
                for i in input:
                    pass
            raise

        finally:
            for i in range(self._num_followers):
                put_item(EXIT)
            self._que_err.put(EXIT)
1138717
def clear(self):
        """"""

        while True:
            try:
                session = self._sessions.get(block=False)
            except queue.Empty:
                break
            else:
                session.delete()
714480
def stop(self):
        """"""
        consumed_energy = collections.defaultdict(dict)
        if not self.is_running():
            return None
        # cpu-energy-meter expects SIGINT to stop and report its result
        self._measurement_process.send_signal(signal.SIGINT)
        (out, err) = self._measurement_process.communicate()
        assert self._measurement_process.returncode is not None
        if self._measurement_process.returncode:
            logging.debug(
                "Energy measurement terminated with return code %s",
                self._measurement_process.returncode)
        self._measurement_process = None
        for line in err.splitlines():
            logging.debug("energy measurement stderr: %s", line)
        for line in out.splitlines():
            line = line.decode('ASCII')
            logging.debug("energy measurement output: %s", line)
            match = re.match(r'cpu(\d+)_([a-z]+)_joules=(\d+\.?\d*)', line)
            if not match:
                continue

            cpu, domain, energy = match.groups()
            cpu = int(cpu)
            energy = Decimal(energy)

            consumed_energy[cpu][domain] = energy
        return consumed_energy
20701
def consume(self):
        """"""
        if self.match:
            self.pos = self.match.end()
            if self.match.group()[-1] == '\n':
                self._update_prefix()
            self.match = None
977826
def pop(queue, quantity=1, is_runner=False):
    '''
    
    '''
    cmd = 'SELECT name FROM {0}'.format(queue)
    if quantity != 'all':
        try:
            quantity = int(quantity)
        except ValueError as exc:
            error_txt = ('Quantity must be an integer or "all".\n'
                         'Error: "{0}".'.format(exc))
            raise SaltInvocationError(error_txt)
        cmd = ''.join([cmd, ' LIMIT {0}'.format(quantity)])
    log.debug('SQL Query: %s', cmd)
    con = _conn(queue)
    items = []
    with con:
        cur = con.cursor()
        result = cur.execute(cmd).fetchall()
        if result:
            items = [item[0] for item in result]
            itemlist = '","'.join(items)
            _quote_escape(itemlist)
            del_cmd = '''DELETE FROM {0} WHERE name IN ("{1}")'''.format(
                queue, itemlist)

            log.debug('SQL Query: %s', del_cmd)

            cur.execute(del_cmd)
        con.commit()
    if is_runner:
        items = [salt.utils.json.loads(item[0].replace("'", '"')) for item in result]
    log.info(items)
    return items
116339
def run(self):
        
        while True:
            self._event.clear()
            self._queue.get().run(self._event)
251666
function nextTick() {
  if (draining) {
    return;
  }
  scheduled = false;
  draining = true;
  var len = queue.length;
  var timeout = setTimeout(cleanUpNextTick);
  while (len) {
    currentQueue = queue;
    queue = [];
    while (currentQueue && ++queueIndex < len) {
      currentQueue[queueIndex].run();
    }
    queueIndex = -1;
    len = queue.length;
  }
  currentQueue = null;
  queueIndex = -1;
  draining = false;
  clearTimeout(timeout);
}
836955
def clean(self):
        
        for _, item in self.queue.items():
            if item['status'] in ['paused', 'running', 'stopping', 'killing']:
                item['status'] = 'queued'
                item['start'] = ''
                item['end'] = ''
289563
def finish(self, data=''):
        '''
        
        '''
        self.pending += data
        self.streaming = False
        for i in self:
            yield i
352156
function() {

        if (purging) {
            return;
        }

        purging = true;
        for (var i in queues) {
            var q = queues[i];
            if (q.autopurge && q.finished) {
                _purge(q.tId);
                delete queues[i];
            }
        }

        purging = false;
    }