Blocking function that can be run directly, if so would probably
        want to specify 'stop_at_empty' to true, or have a separate process
        adding items to the queue.
514783
def main_loop(self, stop_at_empty=False):
        
        try:
            while True:
                self.hook_pre_command()
                self._check_command_queue()
                if self.run_until and self.run_until < datetime.datetime.now():
                    self.log.info("Time limit reached")
                    break
                if self._end.value:
                    break
                if self._pause.value:
                    time.sleep(.5)
                    continue
                self.hook_post_command()
                self._update_tasks()
                task_id = self._free_task()
                if task_id:
                    try:
                        task = self.task_queue.get(timeout=.1)
                    except queue.Empty:
                        if stop_at_empty:
                            break
                        self._return_task(task_id)
                    else:
                        self.hook_pre_task()
                        self.log.debug("Starting task on {0}".format(task_id))
                        try:
                            self._start_task(task_id, task)
                        except Exception as err:
                            self.log.exception("Could not start task {0} -"
                                               " {1}".format(task_id, err))
                        else:
                            self.hook_post_task()
        finally:
            self.log.info("Ending main loop")
474976
async def trigger(self, event, kwargs):
        
        await self._queue.put((event, kwargs))
        self._resume_processing.set()
580401
def PopItem(self):
    
    try:
      # If no timeout is specified the queue will block if empty otherwise
      # a Queue.Empty exception is raised.
      return self._queue.get(timeout=self._timeout)

    except KeyboardInterrupt:
      raise errors.QueueClose

    # If close() is called on the multiprocessing.Queue while it is blocking
    # on get() it will raise IOError.
    except IOError:
      raise errors.QueueClose

    except Queue.Empty:
      raise errors.QueueEmpty
678157
function mainloop(){
		// console.log('mainloop()');
		var queue = [];
		if( !_this.canceled && _this.queue.length ){
			// var row = _this.queue.shift();
			queue = _this.queue;
			_this.queue = [];

			it79.ary(
				queue,
				5,
				function(it1, row, idx){
					searchInFile(row, function(){
						if( _this.canceled ){
							it1.break();
							return;
						}
						it1.next();
						return;
					});
				},
				function(){
					if( _this.canceled ){
						complete();
						return;
					}
				}
			);
		}

		if( _this.canceled || statusFilelist == true && !_this.queue.length && countTarget == countDone ){
			complete();
			return;
		}

		_this.mainloopTimer = setTimeout( mainloop, 3);
		return;
	}
433009
def _flush_queue(self, q, ignore_priority=False):
        
        assert isinstance(q, PriorityQueue)

        current_timestamp = compute_release_time(lag_in_minutes=0)
        for _ in range(len(q)):
            entry = q.pop()
            assert isinstance(entry, PriorityEntry)

            if ignore_priority or entry.release_time < current_timestamp:
                self._resubmit_uow(entry.entry)
            else:
                q.put(entry)
                break
623341
def add_done_callback(self, fn):  # pylint: disable=invalid-name
        
        if self._operation.done:
            _try_callback(self, fn)
        else:
            self._queue.put(dill.dumps(fn))
            if self._process is None:
                self._process = mp.Process(target=self._execute_tasks)
                self._process.start()
545699
def queue(self, *args, **kwargs):
        
        self.scraper.task_manager.put(self, args, kwargs)
        return self
700620
protected void processQueue() {
        try {
            QueueItem item = queue.take();
            client.addMultipleCounterDataPoints(item.tenantId, item.data);
        } catch (InterruptedException e) {
            // TODO better logging of this unlikely error
            e.printStackTrace();
            return;
        }
    }
230262
function(o) {
            var id = (L.isString(o)) ? o : o.tId,
                q = queues[id];
            if (q) {
                q.aborted = true;
            }
        }
246228
def cancel(self, cancel_running=True, mark_completed_as_cancelled=False):
    

    with self._lock:
      for future in self._queue:
        future.cancel(mark_completed_as_cancelled)
      if cancel_running:
        for future in self._running:
          future.cancel(mark_completed_as_cancelled)
      self._queue.clear()
595370
function() {
			try {
				if (fn) {
					/**
					 * Insert a done() or ok() argument to other needed arguments
					 */
					syntheticArgs.unshift(function() {
						/**
						 * Call the next in queue
						 */
						$this.next.apply($this, arguments);
					});
					/**
					 * Call the function finally
					 */
					fn.apply(this, syntheticArgs);
				} else {
					syntheticArgs = syntheticArgs || [];
					/**
					 * If no function passed, call the next in queue
					 */
					$this.next.apply(this, syntheticArgs);
				}
			} catch(e) {
				/**
				 * An error caught is thrown directly to the catch handler, if any
				 */
				if (this.onCatch) {
					this.onCatch(e);
				} else {
					throw e;
				}
			}
		}
364648
def move(self, queue_item, status):
        

        items = self.__get_var("items_" + queue_item.status)

        del items[queue_item.get_hash()]
        self.count_total -= 1

        queue_item.status = status
        self.add(queue_item)
1141667
function setBlocking(blocking) {
    var out = process.stdout, err = process.stderr;
    [out, err].forEach(function (stream) {
        if (stream._handle && stream.isTTY && chek_1.isFunction(stream._handle.setBlocking))
            stream._handle.setBlocking(blocking);
    });
}
1366694
function run() {
  const current = now();
  const queue = timeoutQueue.slice();
  let interval = INTERVAL_MAX;

  timeoutQueue.length = 0;

  // Reset
  if (runRafId > 0 || runTimeoutId > 0) {
    stop();
  }

  for (let i = queue.length - 1; i >= 0; i--) {
    const item = queue[i];

    if (!item.cancelled) {
      const duration = item.time - current;

      if (duration <= 0) {
        if (isDev) {
          debug('timeout triggered for "%s" at %s', item.id, new Date().toLocaleTimeString());
        }
        item.fn.apply(item.fn, item.args);
      } else {
        // Store smallest duration
        if (duration < interval) {
          interval = duration;
        }
        timeoutQueue.push(item);
      }
    }
  }

  // Loop
  if (timeoutQueue.length > 0) {
    // Use raf if requested interval is less than cutoff
    if (interval < INTERVAL_CUTOFF) {
      runRafId = raf(run);
    } else {
      runTimeoutId = setTimeout(run, interval);
    }
  }
}
658476
function enqueue(){
		var tasks = argumentFilter(arguments);
		queued.push({ tasks:tasks });
		// Timeout needed to increment expected, if next item exists.
		// If it run without timeout, expected always be 0 and the functions
		// will be executed immediately obtaining undefined as parameter.
		setTimeout(function(){if (! expected) runQueue();},1);
		return enqueue;
	}
1011019
def blocking(func, *args, **kwargs):
    
    pool = get_io_pool()
    fut = pool.submit(func, *args, **kwargs)
    return fut.result()
652912
function _runFileQueue() {
  if (!settings) settings = require('./settings');
  const simultaneous = settings.get('load-simultaneously') || 10;

  if ((loading < simultaneous) && (fileQueue.length)) {
    loading++;
    fileQueue.shift()();
  }
}