Example #1
0
def create_queue(c, queue_name, visibility_timeout=None):
    q = c.get_queue(queue_name)
    if not q == None:
        raise Exception("Queue by name '%s' already exists!" % (queue_name))
    log.info("Creating queue '%s' with visibility timeout %s" %
             (queue_name, visibility_timeout))
    c.create_queue(queue_name, visibility_timeout)
Example #2
0
File: sqsctl.py Project: tml/norc
def clear_queue(c, queue_name, use_api):
    q = c.get_queue(queue_name)
    if q == None:
        raise Exception("No queue exists by name '%s'" % (queue_name))
    if use_api:
        log.info("Clearing q '%s' using method recommended in API (had %s messages)" % (queue_name, q.count()))
        q.clear()
    else:
        # clearing is slow & unreliable for some reason.  Just delete it and recreate it.
        log.info("Clearing q using deletion '%s' (had %s messages)" % (queue_name, q.count()))
        visibility_timeout = q.get_timeout()
        delete_queue(c, queue_name)
        wait = 65
        log.info("Waiting %s seconds before recreating queue" % (wait))
        time.sleep(wait)# amazon forces us to wait 1 minute before creating a queue by the same name
        create_queue(c, queue_name, visibility_timeout=visibility_timeout)
Example #3
0
def clear_queue(c, queue_name, use_api):
    q = c.get_queue(queue_name)
    if q == None:
        raise Exception("No queue exists by name '%s'" % (queue_name))
    if use_api:
        log.info(
            "Clearing q '%s' using method recommended in API (had %s messages)"
            % (queue_name, q.count()))
        q.clear()
    else:
        # clearing is slow & unreliable for some reason.  Just delete it and recreate it.
        log.info("Clearing q using deletion '%s' (had %s messages)" %
                 (queue_name, q.count()))
        visibility_timeout = q.get_timeout()
        delete_queue(c, queue_name)
        wait = 65
        log.info("Waiting %s seconds before recreating queue" % (wait))
        time.sleep(
            wait
        )  # amazon forces us to wait 1 minute before creating a queue by the same name
        create_queue(c, queue_name, visibility_timeout=visibility_timeout)
Example #4
0
File: sqsctl.py Project: tml/norc
def create_queue(c, queue_name, visibility_timeout=None):
    q = c.get_queue(queue_name)
    if not q == None:
        raise Exception("Queue by name '%s' already exists!" % (queue_name))
    log.info("Creating queue '%s' with visibility timeout %s" % (queue_name, visibility_timeout))
    c.create_queue(queue_name, visibility_timeout)
Example #5
0
File: sqsctl.py Project: tml/norc
def delete_queue(c, queue_name):
    q = c.get_queue(queue_name)
    if q == None:
        raise Exception("No queue exists by name '%s'" % (queue_name))
    log.info("Deleting q '%s' (had %s messages)" % (queue_name, q.count()))
    q.delete()
Example #6
0
def delete_queue(c, queue_name):
    q = c.get_queue(queue_name)
    if q == None:
        raise Exception("No queue exists by name '%s'" % (queue_name))
    log.info("Deleting q '%s' (had %s messages)" % (queue_name, q.count()))
    q.delete()