How to use the amqp.exceptions.NotFound function in amqp

To help you get started, we’ve selected a few amqp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nameko / nameko / test / amqp / test_publish.py View on Github external
def test_confirms_enabled(self, rabbit_config):
        amqp_uri = rabbit_config['AMQP_URI']

        with pytest.raises(NotFound):
            with get_producer(amqp_uri) as producer:
                producer.publish(
                    "msg", exchange="missing", routing_key="key"
                )
github nameko / nameko / test / standalone / test_event_dispatcher.py View on Github external
def test_mandatory_delivery_no_exchange(self, rabbit_config):
        # requesting mandatory delivery will result in an exception
        # if the exchange does not exist
        dispatch = event_dispatcher(rabbit_config, mandatory=True)
        with pytest.raises(NotFound):
            dispatch("bogus", "bogus", "payload")
github EUDAT-B2SHARE / b2share / b2share / modules / upgrade / upgrades / common.py View on Github external
def elasticsearch_index_destroy(alembic, verbose):
    """Destroy the elasticsearch indices and indexing queue."""
    # Delete "records" index as it might have been created during the upgrade.
    # This happens when the indices have not been initialized yet and are
    # indexed. Normally "records" should be an alias, not an index.
    current_search_client.indices.delete(index='records', ignore=[404])
    for _ in current_search.delete(ignore=[400, 404]):
        pass
    queue = current_app.config['INDEXER_MQ_QUEUE']
    with establish_connection() as c:
        q = queue(c)
        try:
            q.delete()
        except amqp.exceptions.NotFound:
            pass
github smetj / wishbone / wishbone / iomodules / broker.py View on Github external
def do(self, *args, **kwargs):
            sleep_seconds=1
            while self.block() == True:
                try:
                    fn(self, *args, **kwargs)
                    break
                except NotFound as err:
                    self.logging.error("AMQP error. Function: %s Reason: %s"%(fn.__name__,err))
                    if self.auto_create == True:
                        self.brokerCreateQueue(kwargs["consume_queue"])
                except ConnectionError as err:
                    sleep_seconds*=2
                    self.logging.error("AMQP error. Function: %s Reason: %s"%(fn.__name__,err))
                except Exception as err:
                    sleep_seconds*=2
                    self.logging.error("AMQP error. Function: %s Reason: %s"%(fn.__name__,err))
                sleep(sleep_seconds)
                self.logging.info("Sleeping for %s seconds."%sleep_seconds)
        return do
github ssfdust / full-stack-flask-smorest / app / extensions / rpcstore / __init__.py View on Github external
from kombu import Connection, pools
        from flask import current_app

        conn = Connection(current_app.config["CELERY_BROKER_URL"], heartbeat=0)
        pool = pools.connections[conn]

        with pool.acquire_channel(block=True) as (_, channel):
            binding = self.queue(channel)

            for _ in range(self.limit):
                try:
                    msg = binding.get(accept=["json"], no_ack=no_ack)
                    if not msg:
                        break
                    yield msg
                except NotFound:
                    break