示例#1
0
文件: agents.py 项目: adamchainz/cell
 def reset(self):
     debug('Resetting active actors')
     for actor in values(self.registry):
         if actor.consumer:
             ignore_errors(self.connection, actor.consumer.cancel)
         actor.connection = self.connection
         self._start_actor_consumer(actor)
示例#2
0
文件: agents.py 项目: adamchainz/cell
 def kill(self, actor_id):
     if actor_id not in self.registry:
         raise Actor.Next()
     else:
         actor = self.registry.pop(actor_id)
         if actor.consumer and actor.consumer.channel:
             ignore_errors(self.connection, actor.consumer.cancel)
示例#3
0
 def shutdown(self, c):
     """Shutdown task consumer."""
     if c.task_consumer:
         self.stop(c)
         debug('Closing consumer channel...')
         ignore_errors(c, c.task_consumer.close)
         c.task_consumer = None
示例#4
0
 def stop(self, c):
     channels = set()
     for consumer in self.consumers or []:
         ignore_errors(c.connection, consumer.cancel)
         if consumer.channel:
             channels.add(consumer.channel)
     for channel in channels:
         ignore_errors(c.connection, channel.close)
示例#5
0
 def _close(self, c, cancel_consumers=True):
     channels = set()
     for consumer in self.consumers or []:
         if cancel_consumers:
             ignore_errors(c.connection, consumer.cancel)
         if consumer.channel:
             channels.add(consumer.channel)
     for channel in channels:
         ignore_errors(c.connection, channel.close)
示例#6
0
    def stop(self, c):
        if c.event_dispatcher:
            # remember changes from remote control commands:
            self.groups = c.event_dispatcher.groups

            # close custom connection
            if c.event_dispatcher.connection:
                ignore_errors(c, c.event_dispatcher.connection.close)
            ignore_errors(c, c.event_dispatcher.close)
            c.event_dispatcher = None
示例#7
0
文件: agents.py 项目: adamchainz/cell
 def _shutdown(self, cancel=True, close=True, clear=True):
     try:
         for actor in values(self.registry):
             if actor and actor.consumer:
                 if cancel:
                     ignore_errors(self.connection,
                                   actor.consumer.cancel)
                 if close and actor.consumer.channel:
                     ignore_errors(self.connection,
                                   actor.consumer.channel.close)
     finally:
         if clear:
             self.registry.clear()
示例#8
0
 def test_ignore_errors(self):
     l = MyKombuConsumer(self.buffer.put, timer=self.timer, app=self.app)
     l.connection_errors = (AttributeError, KeyError, )
     l.channel_errors = (SyntaxError, )
     ignore_errors(l, Mock(side_effect=AttributeError('foo')))
     ignore_errors(l, Mock(side_effect=KeyError('foo')))
     ignore_errors(l, Mock(side_effect=SyntaxError('foo')))
     with self.assertRaises(IndexError):
         ignore_errors(l, Mock(side_effect=IndexError('foo')))
示例#9
0
 def test_ignore_errors(self):
     c = self.NoopConsumer()
     c.connection_errors = (AttributeError, KeyError,)
     c.channel_errors = (SyntaxError,)
     ignore_errors(c, Mock(side_effect=AttributeError('foo')))
     ignore_errors(c, Mock(side_effect=KeyError('foo')))
     ignore_errors(c, Mock(side_effect=SyntaxError('foo')))
     with pytest.raises(IndexError):
         ignore_errors(c, Mock(side_effect=IndexError('foo')))
示例#10
0
    def test_ignored(self):
        connection = Mock()
        connection.channel_errors = (KeyError,)
        connection.connection_errors = (KeyError,)

        with ignore_errors(connection):
            raise KeyError()

        def raising():
            raise KeyError()

        ignore_errors(connection, raising)

        connection.channel_errors = connection.connection_errors = ()

        with self.assertRaises(KeyError):
            with ignore_errors(connection):
                raise KeyError()
示例#11
0
def test_ignore_errors():
    connection = Mock()
    connection.channel_errors = (KeyError,)
    connection.connection_errors = (KeyError,)

    with ignore_errors(connection):
        raise KeyError()

    def raising():
        raise KeyError()

    ignore_errors(connection, raising)

    connection.channel_errors = connection.connection_errors = ()

    with pytest.raises(KeyError):
        with ignore_errors(connection):
            raise KeyError()
示例#12
0
文件: consumer.py 项目: frol/celery
 def shutdown(self, c):
     # We must set self.connection to None here, so
     # that the green pidbox thread exits.
     connection, c.connection = c.connection, None
     if connection:
         ignore_errors(connection, connection.close)
示例#13
0
 def stop(self, c):
     if c.task_consumer:
         debug('Cancelling task consumer...')
         ignore_errors(c, c.task_consumer.cancel)
示例#14
0
文件: pidbox.py 项目: zpl/celery
 def shutdown(self, c):
     self.on_stop()
     if self.consumer:
         debug('Canceling broadcast consumer...')
         ignore_errors(c, self.consumer.cancel)
     self.stop(self.c)
示例#15
0
 def _close_channel(self, c):
     if self.node and self.node.channel:
         ignore_errors(c, self.node.channel.close)
示例#16
0
 def shutdown(self, c):
     self.on_stop()
     if self.consumer:
         debug('Cancelling broadcast consumer...')
         ignore_errors(c, self.consumer.cancel)
     self.stop(self.c)
示例#17
0
文件: bootsteps.py 项目: Dalar/celery
 def stop(self, c):
     for consumer in self.consumers or []:
         ignore_errors(c.connection, consumer.cancel)
示例#18
0
文件: bootsteps.py 项目: Dalar/celery
 def shutdown(self, c):
     self.stop(c)
     for consumer in self.consumers or []:
         if consumer.channel:
             ignore_errors(c.connection, consumer.channel.close)
示例#19
0
文件: consumer.py 项目: EDHsu/celery
 def shutdown(self, c):
     if c.task_consumer:
         self.stop(c)
         debug("Closing consumer channel...")
         ignore_errors(c, c.task_consumer.close)
         c.task_consumer = None
示例#20
0
 def shutdown(self, c):
     if c.task_consumer:
         self.stop(c)
         debug('Closing consumer channel...')
         ignore_errors(c, c.task_consumer.close)
         c.task_consumer = None
示例#21
0
文件: pidbox.py 项目: zpl/celery
 def _close_channel(self, c):
     if self.node and self.node.channel:
         ignore_errors(c, self.node.channel.close)
示例#22
0
文件: consumer.py 项目: frol/celery
 def stop(self, c):
     if c.event_dispatcher:
         ignore_errors(c, c.event_dispatcher.close)
         c.event_dispatcher = None
示例#23
0
 def stop(self, c):
     for consumer in self.consumers or []:
         ignore_errors(c.connection, consumer.cancel)
示例#24
0
 def shutdown(self, c):
     # We must set self.connection to None here, so
     # that the green pidbox thread exits.
     connection, c.connection = c.connection, None
     if connection:
         ignore_errors(connection, connection.close)
示例#25
0
 def shutdown(self, c):
     self.stop(c)
     for consumer in self.consumers or []:
         if consumer.channel:
             ignore_errors(c.connection, consumer.channel.close)
示例#26
0
文件: consumer.py 项目: frol/celery
 def stop(self, c):
     if c.task_consumer:
         debug('Cancelling task consumer...')
         ignore_errors(c, c.task_consumer.cancel)
示例#27
0
 def stop(self, c):
     if c.event_dispatcher:
         if c.event_dispatcher.connection:
             ignore_errors(c, c.event_dispatcher.connection.close)
         ignore_errors(c, c.event_dispatcher.close)
         c.event_dispatcher = None