def get_client(hub=None, **kwargs): hub = hub or get_event_loop() try: return hub._current_http_client except AttributeError: client = hub._current_http_client = Client(hub, **kwargs) return client
def __init__(self, *args, **kwargs): if boto is None: raise ImportError('boto is not installed') super(Channel, self).__init__(*args, **kwargs) # SQS blows up if you try to create a new queue when one already # exists but with a different visibility_timeout. This prepopulates # the queue_cache to protect us from recreating # queues that are known to already exist. try: queues = self.sqs.get_all_queues(prefix=self.queue_name_prefix) except exception.SQSError as exc: if exc.status == 403: raise RuntimeError( 'SQS authorization error, access_key={0}'.format( self.sqs.access_key)) raise else: self._queue_cache.update({ queue.name: queue for queue in queues }) # The drain_events() method stores extra messages in a local # Deque object. This allows multiple messages to be requested from # SQS at once for performance, but maintains the same external API # to the caller of the drain_events() method. self._queue_message_cache = collections.deque() self.hub = kwargs.get('hub') or get_event_loop()
def __init__(self, *args, **kwargs): if boto is None: raise ImportError('boto is not installed') super(Channel, self).__init__(*args, **kwargs) # SQS blows up if you try to create a new queue when one already # exists but with a different visibility_timeout. This prepopulates # the queue_cache to protect us from recreating # queues that are known to already exist. try: queues = self.sqs.get_all_queues(prefix=self.queue_name_prefix) except exception.SQSError as exc: if exc.status == 403: raise RuntimeError( 'SQS authorization error, access_key={0}'.format( self.sqs.access_key)) raise else: self._queue_cache.update({queue.name: queue for queue in queues}) # The drain_events() method stores extra messages in a local # Deque object. This allows multiple messages to be requested from # SQS at once for performance, but maintains the same external API # to the caller of the drain_events() method. self._queue_message_cache = collections.deque() self.hub = kwargs.get('hub') or get_event_loop()
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 get_client(hub=None, **kwargs): """Get or create HTTP client bound to the current event loop.""" hub = hub or get_event_loop() try: return hub._current_http_client except AttributeError: client = hub._current_http_client = Client(hub, **kwargs) return client
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 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 __init__(self, *args, **kwargs): if boto3 is None: raise ImportError('boto3 is not installed') super(Channel, self).__init__(*args, **kwargs) # SQS blows up if you try to create a new queue when one already # exists but with a different visibility_timeout. This prepopulates # the queue_cache to protect us from recreating # queues that are known to already exist. self._update_queue_cache(self.queue_name_prefix) self.hub = kwargs.get('hub') or get_event_loop()
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 __init__(self, *args, **kwargs): if boto is None: raise ImportError('boto is not installed') super(Channel, self).__init__(*args, **kwargs) # SQS blows up if you try to create a new queue when one already # exists but with a different visibility_timeout. This prepopulates # the queue_cache to protect us from recreating # queues that are known to already exist. self._update_queue_cache(self.queue_name_prefix) # The drain_events() method stores extra messages in a local # Deque object. This allows multiple messages to be requested from # SQS at once for performance, but maintains the same external API # to the caller of the drain_events() method. self._queue_message_cache = collections.deque() self.hub = kwargs.get('hub') or get_event_loop()
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()