当前位置: 首页>>代码示例>>Python>>正文


Python ActorRegistry.stop_all方法代码示例

本文整理汇总了Python中pykka.registry.ActorRegistry.stop_all方法的典型用法代码示例。如果您正苦于以下问题:Python ActorRegistry.stop_all方法的具体用法?Python ActorRegistry.stop_all怎么用?Python ActorRegistry.stop_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykka.registry.ActorRegistry的用法示例。


在下文中一共展示了ActorRegistry.stop_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
    def _run(self):
        """
        The actor's main method.

        :class:`pykka.gevent.GeventActor` expects this method to be named
        :meth:`_run`.

        :class:`ThreadingActor` expects this method to be named :meth:`run`.
        """
        self.on_start()
        while self._actor_runnable:
            try:
                message = self.actor_inbox.get(False)
                _logger.debug('Actor {} got message {}'.format(self, message))
                try:
                    response = self._handle_receive(message)
                    if 'reply_to' in message:
                        message['reply_to'].set(response)
                except Exception as exception:
                    if 'reply_to' in message:
                        _logger.debug('Exception returned from %s to caller:' %
                            self, exc_info=_sys.exc_info())
                        message['reply_to'].set_exception(exception)
                    else:
                        self._handle_failure(*_sys.exc_info())
                except BaseException as exception:
                    exception_value = _sys.exc_info()[1]
                    _logger.debug('%s in %s. Stopping all actors.' %
                        (repr(exception_value), self))
                    self.stop()
                    _ActorRegistry.stop_all()
            except _queue.Empty:
                pass
开发者ID:zombiecalypse,项目名称:pykka,代码行数:35,代码来源:actor.py

示例2: scan_command

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
def scan_command(directory, tagfile='STAG.sqlite', verbose=False):
    """Scan a directory tree for definitions and references."""

    init_logging(verbose)

    with StorageManager(Storage(tagfile)) as s:
        s.clear_defs()

        storage = StorageActor.start(s)
        parser_map = [
            (list(p.patterns()),
             ParserActor.start(p.create_parser(), storage))
            for p in parser_plugins()]

        dispatcher = DispatcherActor.start(parser_map)

        def dispatch_file(args):
            "Send results of os.walk to the dispatcher."
            dirpath, _, filenames = args
            for fname in filenames:
                dispatcher.tell({
                    'command': 'dispatch',
                    'filename': os.path.join(dirpath, fname)
        })

        emap(dispatch_file, os.walk(directory))

        # Shut everything down.
        ActorRegistry.stop_all()
开发者ID:abingham,项目名称:stag,代码行数:31,代码来源:app.py

示例3: _actor_loop

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
    def _actor_loop(self):
        """
        The actor's event loop.

        This is the method that will be executed by the thread or greenlet.
        """
        self.on_start()
        while self._actor_runnable:
            message = self.actor_inbox.get()
            try:
                response = self._handle_receive(message)
                if 'reply_to' in message:
                    message['reply_to'].set(response)
            except Exception:
                if 'reply_to' in message:
                    _logger.debug(
                        'Exception returned from %s to caller:' % self,
                        exc_info=_sys.exc_info())
                    message['reply_to'].set_exception()
                else:
                    self._handle_failure(*_sys.exc_info())
            except BaseException:
                exception_value = _sys.exc_info()[1]
                _logger.debug(
                    '%s in %s. Stopping all actors.' %
                    (repr(exception_value), self))
                self._stop()
                _ActorRegistry.stop_all()
开发者ID:davisein,项目名称:pykka,代码行数:30,代码来源:actor.py

示例4: stop_all_actors

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
def stop_all_actors():
    num_actors = len(ActorRegistry.get_all())
    while num_actors:
        logger.debug(u'Seeing %d actor and %d non-actor thread(s): %s',
            num_actors, threading.active_count() - num_actors,
            ', '.join([t.name for t in threading.enumerate()]))
        logger.debug(u'Stopping %d actor(s)...', num_actors)
        ActorRegistry.stop_all()
        num_actors = len(ActorRegistry.get_all())
    logger.debug(u'All actors stopped.')
开发者ID:Amli,项目名称:mopidy,代码行数:12,代码来源:process.py

示例5: stop

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
 def stop(self):
     logger.info("exiting ...")
     logger.info("waiting for actors to stop ...")
     try:
         ActorRegistry.stop_all(timeout=10)
     except Exception as ex:
         logger.info("warning - actors failed to stop cleanly")
     logger.info("stopping web server ...")
     stop_web()
     logger.info("finished")
开发者ID:kieranelby,项目名称:mormuvid,代码行数:12,代码来源:app.py

示例6: stop_remaining_actors

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
def stop_remaining_actors():
    num_actors = len(ActorRegistry.get_all())
    while num_actors:
        logger.error(
            u'There are actor threads still running, this is probably a bug')
        logger.debug(u'Seeing %d actor and %d non-actor thread(s): %s',
            num_actors, threading.active_count() - num_actors,
            ', '.join([t.name for t in threading.enumerate()]))
        logger.debug(u'Stopping %d actor(s)...', num_actors)
        ActorRegistry.stop_all()
        num_actors = len(ActorRegistry.get_all())
    logger.debug(u'All actors stopped.')
开发者ID:Dvad,项目名称:mopidy,代码行数:14,代码来源:process.py

示例7: test_runs_parallel

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
 def test_runs_parallel(self):
     self.actor = CoroutineActor.start().proxy()
     first = self.actor.infinite_loop_count.get()
     self.actor.loop_infinitely(0).get()
     second = self.actor.infinite_loop_count.get()
     self.actor.other_method().get()
     called = self.actor.other_called.get()
     third = self.actor.infinite_loop_count.get()
     self.assertTrue(called)
     self.assertLess(first, second)
     self.assertLess(second, third)
     ActorRegistry.stop_all()
开发者ID:zombiecalypse,项目名称:pykka,代码行数:14,代码来源:coroutine_test.py

示例8: _actor_loop

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
    def _actor_loop(self):
        """
        The actor's event loop.

        This is the method that will be executed by the thread or greenlet.
        """
        try:
            self.on_start()
        except Exception:
            self._handle_failure(*sys.exc_info())

        while not self.actor_stopped.is_set():
            message = self.actor_inbox.get()
            reply_to = None
            try:
                reply_to = message.pop('pykka_reply_to', None)
                response = self._handle_receive(message)
                if reply_to:
                    reply_to.set(response)
            except Exception:
                if reply_to:
                    logger.debug(
                        'Exception returned from %s to caller:' % self,
                        exc_info=sys.exc_info())
                    reply_to.set_exception()
                else:
                    self._handle_failure(*sys.exc_info())
                    try:
                        self.on_failure(*sys.exc_info())
                    except Exception:
                        self._handle_failure(*sys.exc_info())
            except BaseException:
                exception_value = sys.exc_info()[1]
                logger.debug(
                    '%s in %s. Stopping all actors.' %
                    (repr(exception_value), self))
                self._stop()
                ActorRegistry.stop_all()

        while not self.actor_inbox.empty():
            msg = self.actor_inbox.get()
            reply_to = msg.pop('pykka_reply_to', None)
            if reply_to:
                if msg.get('command') == 'pykka_stop':
                    reply_to.set(None)
                else:
                    reply_to.set_exception(ActorDeadError(
                        '%s stopped before handling the message' %
                        self.actor_ref))
开发者ID:0xD3ADB33F,项目名称:pykka,代码行数:51,代码来源:actor.py

示例9: run

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
def run(pool_size, *ips):
    # Start resolvers
    resolvers = [Resolver.start_proxy() for _ in range(pool_size)]

    # Distribute work by mapping IPs to resolvers (not blocking)
    hosts = []
    for i, ip in enumerate(ips):
        hosts.append(resolvers[i % len(resolvers)].resolve(ip))

    # Gather results (blocking)
    ip_to_host = zip(ips, get_all(hosts))
    pprint(ip_to_host)

    # Clean up
    ActorRegistry.stop_all()
开发者ID:flaper87,项目名称:pykka,代码行数:17,代码来源:resolver.py

示例10: test_stop_all_stops_last_started_actor_first_if_blocking

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
    def test_stop_all_stops_last_started_actor_first_if_blocking(
            self, mock_method):
        stopped_actors = []
        started_actors = [mock.Mock(name=i) for i in range(3)]
        started_actors[0].stop.side_effect = lambda *a, **kw: \
            stopped_actors.append(started_actors[0])
        started_actors[1].stop.side_effect = lambda *a, **kw: \
            stopped_actors.append(started_actors[1])
        started_actors[2].stop.side_effect = lambda *a, **kw: \
            stopped_actors.append(started_actors[2])
        ActorRegistry.get_all.return_value = started_actors

        ActorRegistry.stop_all(block=True)

        self.assertEqual(stopped_actors[0], started_actors[2])
        self.assertEqual(stopped_actors[1], started_actors[1])
        self.assertEqual(stopped_actors[2], started_actors[0])
开发者ID:benjixx,项目名称:pykka,代码行数:19,代码来源:registry_test.py

示例11: tearDown

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
 def tearDown(self):
     ActorRegistry.stop_all()
开发者ID:PabloTunnon,项目名称:pykka-deb,代码行数:4,代码来源:actor_test.py

示例12: tearDown

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
 def tearDown(self):
     self.log_handler.close()
     ActorRegistry.stop_all()
开发者ID:garindra,项目名称:pykka,代码行数:5,代码来源:logging_test.py

示例13: test_all_actors_can_be_stopped_through_registry

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
 def test_all_actors_can_be_stopped_through_registry(self):
     self.assertEquals(9, len(ActorRegistry.get_all()))
     ActorRegistry.stop_all(block=True)
     self.assertEquals(0, len(ActorRegistry.get_all()))
开发者ID:benjixx,项目名称:pykka,代码行数:6,代码来源:registry_test.py

示例14: test_direct_plain_attribute_access

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
def test_direct_plain_attribute_access():
    actor = AnActor.start().proxy()
    for i in range(10000):
        foo = actor.foo.get()

def test_direct_callable_attribute_access():
    actor = AnActor.start().proxy()
    for i in range(10000):
        actor.func().get()

def test_traversible_plain_attribute_access():
    actor = AnActor.start().proxy()
    for i in range(10000):
        foo = actor.bar.baz.get()

def test_traversible_callable_attribute_access():
    actor = AnActor.start().proxy()
    for i in range(10000):
        actor.bar.func().get()


if __name__ == '__main__':
    try:
        time_it(test_direct_plain_attribute_access)
        time_it(test_direct_callable_attribute_access)
        time_it(test_traversible_plain_attribute_access)
        time_it(test_traversible_callable_attribute_access)
    finally:
        ActorRegistry.stop_all()
开发者ID:okoye,项目名称:pykka,代码行数:31,代码来源:performance.py

示例15: exit_status

# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import stop_all [as 别名]
def exit_status(exit_code):
  settings_listener.stop()
  ActorRegistry.stop_all()
  return exit_code
开发者ID:cigraphics,项目名称:ArchiveBot,代码行数:6,代码来源:wpull_hooks.py


注:本文中的pykka.registry.ActorRegistry.stop_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。