How to use the dramatiq.get_broker function in dramatiq

To help you get started, we’ve selected a few dramatiq 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 Bogdanp / django_dramatiq_example / dashboard / tests.py View on Github external
def setUp(self):
        super().setUp()

        self.broker = dramatiq.get_broker()
        self.worker = dramatiq.Worker(self.broker, worker_timeout=100)
        self.worker.start()
github Bogdanp / dramatiq / tests / test_broker.py View on Github external
def test_broker_uses_rabbitmq_if_not_set():
    # Given that no global broker is set
    dramatiq.broker.global_broker = None

    # If I try to get the global broker
    broker = dramatiq.get_broker()

    # I expect it to be a RabbitmqBroker instance
    assert isinstance(broker, RabbitmqBroker)
github Bogdanp / dramatiq / examples / crawler / profile_example.py View on Github external
def main(args):
    broker = dramatiq.get_broker()
    broker.emit_after("process_boot")
    worker = dramatiq.Worker(broker, worker_threads=1)
    worker.start()

    while True:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            break

    worker.stop()
    broker.close()
github Bogdanp / dramatiq / examples / basic / profile_example.py View on Github external
def main(args):
    broker = dramatiq.get_broker()
    broker.emit_after("process_boot")
    worker = dramatiq.Worker(broker, worker_threads=1)
    worker.start()

    while True:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            break

    worker.stop()
    broker.close()
github Bogdanp / dramatiq / dramatiq / cli.py View on Github external
def import_broker(value):
    module, broker = import_object(value)
    if broker is None:
        return module, get_broker()

    if not isinstance(broker, Broker):
        raise ImportError("%r is not a Broker." % value)
    return module, broker
github Bogdanp / dramatiq_dashboard / dramatiq_dashboard / middleware.py View on Github external
def make_wsgi_middleware(prefix, broker=None):
    broker = broker or dramatiq.get_broker()
    if not isinstance(broker, RedisBroker):
        raise RuntimeError("broker must be a RedisBroker")

    def middleware(app):
        return DashboardMiddleware(app, broker, prefix)
    return middleware