function purges
    :param mq_queue_name: <string> name of the message queue
    :return: number of purged messages
545301
def purge_mq_queue(mq_queue_name):
    
    conn = None
    chan = None
    try:
        conn = Connection()
        chan = conn.connection.channel()
        n = chan.queue_purge(mq_queue_name)
        sys.stdout.write('Purged {0} messages from {1} queue\n'.format(n, mq_queue_name))
        return n
    except Exception as e:
        sys.stderr.write('Unable to purge {0} due to {1}\n'.format(mq_queue_name, e))
    finally:
        if chan is not None:
            chan.close()
        if conn is not None:
            conn.close()
1196896
def get_messages(self, name):
        

        return self._loop.run_coroutine(self._client.get_messages(name))
1232600
public int queue(String name) {
    Queue<?> q = isEmpty() ? null : queue(get(0), name, null);
    return q == null ? 0 : q.size();
  }
1095609
def _view_clear_queue(self, queue_type, queue_id):
        """"""
        response = {
            'status': 'failure'
        }
        try:
            request_data = json.loads(request.data)
        except Exception, e:
            response['message'] = e.message
            return jsonify(**response), 400
        
        request_data.update({
            'queue_type': queue_type,
            'queue_id': queue_id
        })
        try:
            response = self.sq.clear_queue(**request_data)
        except Exception, e:
            response['message'] = e.message
            return jsonify(**response), 400

        return jsonify(**response)
962532
def queue_exists(self, name):
        
        try:
            queue = self._manager.head(name)
            return True
        except exc.NotFound:
            return False
1216553
def get_queue(cls, name, priority=0, **fields_if_new):
        
        queue_kwargs = {'name': name, 'priority': priority}
        retries = 0
        while retries < 10:
            retries += 1
            try:
                queue, created = cls.get_or_connect(**queue_kwargs)
            except IndexError:
                # Failure during the retrieval https://friendpaste.com/5U63a8aFuV44SEgQckgMP
                # => retry
                continue
            except ValueError:
                # more than one (race condition https://github.com/yohanboniface/redis-limpyd/issues/82 ?)
                try:
                    queue = cls.collection(**queue_kwargs).instances()[0]
                except IndexError:
                    # but no more now ?!
                    # => retry
                    continue
                else:
                    created = False

            # ok we have our queue, stop now
            break

        if created and fields_if_new:
            queue.set_fields(**fields_if_new)

        return queue
929536
def delete_queue(queues):
    """"""
    current_queues.delete(queues=queues)
    click.secho(
        'Queues {} have been deleted.'.format(
            queues or current_queues.queues.keys()),
        fg='green'
    )
1308853
def flush( queue_name )
      # It can take a long time to flush all of the messages
      # on a server, so we'll set the read timeout to something
      # much higher than usual.
      connection.with_additional_read_timeout(60) do
        req  = KJess::Request::Flush.new( :queue_name => queue_name )
        resp = send_recv( req )
        return KJess::Response::End === resp
      end
    end
962836
def delete_queue():
    """"""
    def action(queue):
        queue.delete()
        click.secho('Indexing queue has been deleted.', fg='green')
        return queue
    return action
425226
private void purgeChannel(MessageChannel channel) {
        if (channel instanceof QueueChannel) {
            List<Message<?>> messages = ((QueueChannel)channel).purge(messageSelector);
            
            if (log.isDebugEnabled()) {
                log.debug("Purged channel " + ((QueueChannel)channel).getComponentName() + " - removed " + messages.size() + " messages");
            }
        }
    }
493811
def dump_queue(self, *names):
        
        conn = redis.StrictRedis(connection_pool=self.pool)
        for name in names:
            if name == 'worker':
                logger.debug('last worker: ' + conn.get(self._key_worker()))
            elif name == 'available':
                logger.debug('available: ' +
                             str(conn.zrevrange(self._key_available(), 0, -1,
                                                withscores=True)))
            elif name == 'priorities':
                logger.debug('priorities: ' +
                             str(conn.hgetall(self._key_priorities())))
            elif name == 'expiration':
                logger.debug('expiration: ' +
                             str(conn.zrevrange(self._key_expiration(), 0, -1,
                                                withscores=True)))
            elif name == 'workers':
                logger.debug('workers: ' +
                             str(conn.hgetall(self._key_workers())))
            elif name.startswith('reservations_'):
                item = name[len('reservations_'):]
                logger.debug('reservations for ' + item + ': ' +
                             str(conn.smembers(self._key_reservations(item))))
1219764
def queue_purge(self, queue, **kwargs):
        """"""
        qsize = mqueue.qsize()
        mqueue.queue.clear()
        return qsize
1311720
public static void emptyAndRemoveQueue( String strQueueName )
  {
    TaskQueue taskQueue = QUEUE_MAP.get( strQueueName );
    if( taskQueue != null )
    {
      taskQueue.emptyQueue();
      synchronized( taskQueue._queue )
      {
        taskQueue._shutdown = true;
        taskQueue._queue.notifyAll();
      }
      QUEUE_MAP.remove( strQueueName );
    }
  }
850817
def _mini_purge(self, spiderid, appid, crawlid):
        '''
        
        '''
        total_purged = 0

        match_string = '{sid}:*:queue'.format(sid=spiderid)
        # using scan for speed vs keys
        for key in self.redis_conn.scan_iter(match=match_string):
            for item in self.redis_conn.zscan_iter(key):
                item_key = item[0]
                item = ujson.loads(item_key)
                if 'meta' in item:
                    item = item['meta']

                if item['appid'] == appid and item['crawlid'] == crawlid:
                    self.redis_conn.zrem(key, item_key)
                    total_purged = total_purged + 1

        return total_purged
925303
def pop(self, queue_name):
        
        task_id = self.conn.lpop(queue_name)
        data = self.conn.get(task_id)
        self.conn.delete(task_id)
        return data
85540
public synchronized void removeUpdatesForQueue( String queueName )
    {
    	Iterator<TransactionItem> entries = items.iterator();
    	while (entries.hasNext())
		{
    		TransactionItem item = entries.next();
    		if (item.getDestination().getName().equals(queueName))
    		    entries.remove();
		}
    }
678090
protected final void deleteQueue( String queueName ) throws JMSException
    {
    	transactionSet.removeUpdatesForQueue(queueName);
        engine.deleteQueue(queueName);
    }