def handle(self, queue, *args, **options): fmt = '%(asctime)s %(name)-12s: %(levelname)-8s %(message)s' log_level = 40 - (options['verbosity'] * 10) logging.basicConfig(level=log_level, format=fmt) # TODO: Ensure that failed processing does not requeue task into # work queue set_event_loop(Hub()) kwargs = { 'transport_options': conf.broker_transport_options, } with app.connection(**kwargs) as conn: logger.info("Launching worker") worker = Worker(conn, queues=[Queue(queue)]) worker.connect_max_retries = 1 while True: try: breakers.celery.call(worker.run) except KeyboardInterrupt: logger.info("KeyboardInterrupt, exiting. Bye!") break except breakers.celery.expected_errors: rest_val = 5 logger.warning( "Open circuit detected. " "Sleeping for %s seconds and then will try again.", rest_val) time.sleep(rest_val)
def tearDown(self): try: super(HubCase, self).tearDown() finally: from kombu.async import set_event_loop if self._prev_hub is not None: set_event_loop(self._prev_hub)
def tearDown(self): try: super(HubCase, self).tearDown() finally: from kombu. async import set_event_loop if self._prev_hub is not None: set_event_loop(self._prev_hub)
def hub(request): from kombu.async import Hub, get_event_loop, set_event_loop _prev_hub = get_event_loop() hub = Hub() set_event_loop(hub) yield hub if _prev_hub is not None: set_event_loop(_prev_hub)
def hub(request): from kombu. async import Hub, get_event_loop, set_event_loop _prev_hub = get_event_loop() hub = Hub() set_event_loop(hub) yield hub if _prev_hub is not None: set_event_loop(_prev_hub)
def hub(request): from kombu.async import Hub, get_event_loop, set_event_loop _prev_hub = get_event_loop() hub = Hub() set_event_loop(hub) def fin(): if _prev_hub is not None: set_event_loop(_prev_hub) request.addfinalizer(fin) return hub
def hub(request): from kombu. async import Hub, get_event_loop, set_event_loop _prev_hub = get_event_loop() hub = Hub() set_event_loop(hub) def fin(): if _prev_hub is not None: set_event_loop(_prev_hub) request.addfinalizer(fin) return hub
def create(self, w): w.hub = get_event_loop() if w.hub is None: required_hub = getattr(w._conninfo, "requires_hub", None) w.hub = set_event_loop((required_hub if required_hub else _Hub)(w.timer)) self._patch_thread_primitives(w) return self
def create(self, w): w.hub = get_event_loop() if w.hub is None: required_hub = getattr(w._conninfo, 'requires_hub', None) w.hub = set_event_loop( (required_hub if required_hub else _Hub)(w.timer)) self._patch_thread_primitives(w) return self
def create(self, w): w.hub = get_event_loop() if w.hub is None: w.hub = set_event_loop(_Hub(w.timer)) self._patch_thread_primitives(w) return self
def setUp(self): from kombu.async import Hub, get_event_loop, set_event_loop self._prev_hub = get_event_loop() self.hub = Hub() set_event_loop(self.hub) super(HubCase, self).setUp()
def setUp(self): from kombu. async import Hub, get_event_loop, set_event_loop self._prev_hub = get_event_loop() self.hub = Hub() set_event_loop(self.hub) super(HubCase, self).setUp()
def fin(): if _prev_hub is not None: set_event_loop(_prev_hub)