Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
super().setUp()
self.broker = dramatiq.get_broker()
self.worker = dramatiq.Worker(self.broker, worker_timeout=100)
self.worker.start()
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)
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()
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()
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
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