Create / get a durable queue and apply namespace if it exists.
764724
def queue(name, arguments = {})
      with_bunny_precondition_handler('queue') do
        namespace = @config[:namespace].to_s.downcase.gsub(/[^-_:\.\w]/, "")
        name = name.prepend(namespace + ":") if namespace.present?
        channel.queue(name, durable: true, arguments: arguments)
      end
    end
575994
def queue(self):
        """"""
        with self.connection_pool.acquire(block=True) as conn:
            return Q(
                self.routing_key,
                exchange=self.exchange,
                routing_key=self.routing_key
            )(conn)
265794
def _emulated(self, timeout=None):
        

        # A set of queues we've already tried.
        tried = set()

        while True:
            # Get the next queue in the cycle, and try to get an item off it.
            try:
                queue = self.cycle.next()
            except StopIteration:
                raise Empty("No queues registered")
            try:
                item = queue.get()
            except Empty:
                # raises Empty when we've tried all of them.
                tried.add(queue.name)
                if tried == self.all:
                    raise
            else:
                return item, queue.name
502163
def create(self):
        
        self.queue = self.scheduler.queue.addSubQueue(self.priority, LockEvent.createMatcher(self.context, self.key),
                                         maxdefault = self.size, defaultQueueClass = CBQueue.AutoClassQueue.initHelper('locker', subqueuelimit = 1))
1297419
def get(self, namespacePrefix):
        """"""
        ns = db.ConfigNamespace.find_one(ConfigNamespace.namespace_prefix == namespacePrefix)
        if not ns:
            return self.make_response('No such namespace: {}'.format(namespacePrefix), HTTP.NOT_FOUND)

        return self.make_response({
            'message': None,
            'namespace': ns
        })
1355815
def add_namespace(self, namespace, interface=None, check_extras=True,
                      load_now=False):
        
        tempo = self._namespaces.get(namespace)

        if tempo is None:
            tempo = _Plugins(namespace, interface, check_extras)
            self._namespaces[namespace] = tempo

        if load_now:
            tempo.load()

        return tempo
1241467
@SuppressWarnings("resource")
	public ISynchronizationPoint<Exception> registerNamespace(String namespace, String path, ClassLoader classLoader) {
		Namespace ns;
		SynchronizationPoint<Exception> sp = new SynchronizationPoint<>();
		synchronized (namespaces) {
			ns = namespaces.get(namespace);
			if (ns == null) {
				ns = new Namespace();
				ns.loading = sp;
				namespaces.put(namespace, ns);
			} else {
				ns.loading.cancel(new CancelException("Namespace overriden"));
				ns.loading = sp;
				ns.languages = null;
			}
		}
		ns.classLoader = classLoader;
		ns.path = path;
		IOProvider.Readable provider = new IOProviderFromPathUsingClassloader(classLoader).get(path + ".languages");
		IO.Readable input;
		try { input = provider == null ? null : provider.provideIOReadable(Task.PRIORITY_RATHER_IMPORTANT); }
		catch (IOException e) {
			sp.error(new Exception("Localized properties for namespace " + namespace
				+ " cannot be loaded because the file " + path + ".languages does not exist", e));
			logger.error(sp.getError().getMessage());
			return sp;
		}
		if (input == null) {
			sp.error(new Exception("Localized properties for namespace " + namespace
				+ " cannot be loaded because the file " + path + ".languages does not exist"));
			logger.error(sp.getError().getMessage());
			return sp;
		}
		AsyncWork<UnprotectedStringBuffer, IOException> read = IOUtil.readFullyAsString(
			input, StandardCharsets.US_ASCII, Task.PRIORITY_RATHER_IMPORTANT);
		Namespace toLoad = ns;
		read.listenAsyncSP(new Task.Cpu.FromRunnable("Read localized properties namespace file", Task.PRIORITY_RATHER_IMPORTANT, () -> {
			List<Namespace.Language> languages = new LinkedList<>();
			UnprotectedStringBuffer str = read.getResult();
			for (UnprotectedStringBuffer s : str.split(',')) {
				s.trim().toLowerCase();
				if (s.length() == 0) continue;
				Namespace.Language l = new Namespace.Language();
				List<UnprotectedStringBuffer> list = s.split('-');
				l.tag = new String[list.size()];
				int i = 0;
				for (UnprotectedStringBuffer us : list) l.tag[i++] = us.asString();
				languages.add(l);
			}
			languages.sort(new Comparator<Namespace.Language>() {
				@Override
				public int compare(Namespace.Language l1, Namespace.Language l2) {
					/* Order:
					 *  tags are alphabetically ordered
					 *  but tags xx-yy are before tag xx
					 */
					int i = 0;
					do {
						if (i == l1.tag.length) return 1;
						if (i == l2.tag.length) return -1;
						int c = l1.tag[i].compareTo(l2.tag[i]);
						if (c != 0) return c;
						i++;
					} while (true);
				}
			});
			toLoad.languages = languages.toArray(new Namespace.Language[languages.size()]);
			// set parents
			for (int i = 0; i < toLoad.languages.length; ++i) {
				// they are ordered, so the parent is after
				int nbI = toLoad.languages[i].tag.length;
				for (int j = i + 1; j < toLoad.languages.length; ++j) {
					int nbJ = toLoad.languages[j].tag.length;
					if (nbJ >= nbI) continue;
					if (ArrayUtil.equals(toLoad.languages[i].tag, 0, toLoad.languages[j].tag, 0, nbJ))
						toLoad.languages[i].parent = toLoad.languages[j];
					break;
				}
			}
			sp.unblock();
			logger.info("Namespace " + namespace + " loaded with " + languages.size() + " languages from " + path);
		}), sp);
		sp.listenInline(() -> { input.closeAsync(); });
		sp.onError((error) -> {
			logger.error("Error loading localized properties namespace file " + path + ".languages", error);
		}
26105
def reserve(cls, queues, res, worker=None, timeout=10):
        
        if isinstance(queues, string_types):
            queues = [queues]
        queue, payload = res.pop(queues, timeout=timeout)
        if payload:
            return cls(queue, payload, res, worker)
644546
public static String createQueue(String name) {
		if (StringUtils.isBlank(name)) {
			return null;
		}
		String queueURL = getQueueURL(name);
		if (queueURL == null) {
			try {
				queueURL = getClient().createQueue(new CreateQueueRequest(name)).getQueueUrl();
			} catch (AmazonServiceException ase) {
				logException(ase);
			} catch (AmazonClientException ace) {
				logger.error("Could not reach SQS. {0}", ace.toString());
			}
		}
		return queueURL;
	}
26175
def queue_exists(self, queue):
        
        try:
            self.channel.queue_declare(queue=queue, passive=True)
        except AMQPChannelException, e:
            if e.amqp_reply_code == 404:
                return False
            raise e
        else:
            return True
929590
def exists(self, qname):
        '''
        
        '''
        try:
            # First if not exists() -> exit
            if self.conn.queue_exists(qname):
                return True
            return False
        except pyrax.exceptions as err_msg:
            log.error('RackSpace API got some problems during '
                      'existing queue check: %s',
                      err_msg)
        return False
872011
def get_queue(name, options = {})
      response = action("GetQueueUrl", {"QueueName" => Queue.sanitize_name("#{queue_prefix}#{name}")}.merge(options))
      
      if response.success?
        Queue.new(self, response.doc.xpath("//QueueUrl").text)
      end

    rescue Bisques::AwsActionError => e
      raise unless e.code == "AWS.SimpleQueueService.NonExistentQueue"
    end
873650
function Queue(queueName, accessKey, secretKey, region) {
  if (!(this instanceof Queue)) return new Queue(queueName, accessKey, secretKey, region);
  var self = this;
  Object.defineProperty(this, '_sqs',{enumerable: false, configurable: false, writable: false,
    value: getSQS(accessKey, secretKey, region)});
  function setQueue(name) {
    debug('set queue: ' + name);
    var parsed;
    if (parsed = /([0-9]{12}\/([^\/]+))\/?$/.exec(name)) {
      self._sqs.setQueue('/' + parsed[1] + '/');
      self.name = parsed[2];
      if (self._init) delete self._init;
    } else if (typeof name === 'string') {
      self.name = name;
      Object.defineProperty(self, '_init',{enumerable: false, configurable: true, writable: true,
        value: getQueueURL(self, name).then(setQueue)});
      self.then = self._init.then;
      self.done = self._init.done;
    } else if (name && typeof name === 'object' && typeof name.then === 'function') {
      self.name = name.toString();
      Object.defineProperty(self, '_init',{enumerable: false, configurable: true, writable: true,
        value: name.then(setQueue)});
      self.then = self._init.then;
      self.done = self._init.done;
    } else {
      throw new Error(JSON.stringify(name) + ' is not a valid queue.');
    }
  }
  setQueue(queueName);
}
1112136
def queue_exc(*arg, **kw):
    """"""
    _self = arg[0]
    if not isinstance(_self, AnsibleUndefinedVariable):
        # Run for AnsibleUndefinedVariable instance
        return
    _rslt_q = None
    for stack_trace in inspect.stack():
        # Check if method to be skipped
        if stack_trace[3] in SKIP_METHODS:
            continue
        _frame = stack_trace[0]
        _locals = inspect.getargvalues(_frame).locals
        if 'self' not in _locals:
            continue
        # Check if current frame instance of worker
        if isinstance(_locals['self'], WorkerProcess):
            # Get queue to add exception
            _rslt_q = getattr(_locals['self'], '_rslt_q')
    if not _rslt_q:
        raise ValueError("No Queue found.")
    # Add interceptor exception
    _rslt_q.put(arg[3].message, interceptor=True)
1306109
def build_queue(action, action_space, build_queue_id):
  """"""
  del action_space
  action.action_ui.production_panel.unit_index = build_queue_id
185612
function Queue (name, redisClient) {
  this.hasQuit = false
  this._name = name
  this.redisClient = redisClient
  this._key = Queue.PREFIX + this.name
}
468386
def cached(namespace=None, service="memory", debug=False):
    
    _service = getattr(debris.services, service)
    def wrapper(_f):
        @functools.wraps(_f)
        def _stash(self, *a, **k):
            if debug is False:
                # this request is cacheable
                try:
                    self.finish(_service.get(namespace))
                except LookupError:
                    _replace_finish(self, namespace, _service)
                    # get the result of this request
                    _f(self, *a, **k)
                return
            # request is not cacheable
            _f(self, *a, **k)
        return _stash
    return wrapper