How to use the pykka.ActorRegistry.get_all function in pykka

To help you get started, we’ve selected a few pykka examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jodal / pykka / tests / test_actor.py View on Github external
def test_actor_processes_all_messages_before_stop_on_self_stops_it(
    actor_ref, events
):
    actor_ref.ask({'command': 'message self then stop'})

    events.greetings_was_received.wait(5)
    assert events.greetings_was_received.is_set()

    events.on_stop_was_called.wait(5)
    assert len(ActorRegistry.get_all()) == 0
github jodal / pykka / tests / test_actor.py View on Github external
def test_all_actors_are_stopped_on_base_exception(events, actor_ref):
    assert len(ActorRegistry.get_all()) == 1
    assert not events.on_stop_was_called.is_set()

    actor_ref.tell({'command': 'raise base exception'})

    events.on_stop_was_called.wait(5)
    assert events.on_stop_was_called.is_set()
    assert len(ActorRegistry.get_all()) == 0

    events.on_stop_was_called.wait(5)
    assert events.on_stop_was_called.is_set()
    assert len(ActorRegistry.get_all()) == 0
github jodal / pykka / tests / test_actor.py View on Github external
def test_actor_is_stopped_when_unhandled_exceptions_are_raised(
    actor_ref, events
):
    assert not events.on_failure_was_called.is_set()

    actor_ref.tell({'command': 'raise exception'})

    events.on_failure_was_called.wait(5)
    assert events.on_failure_was_called.is_set()
    assert len(ActorRegistry.get_all()) == 0
github jodal / pykka / tests / test_registry.py View on Github external
def test_actor_may_be_unregistered_multiple_times_without_error(actor_ref):
    ActorRegistry.unregister(actor_ref)
    assert actor_ref not in ActorRegistry.get_all()

    ActorRegistry.unregister(actor_ref)
    assert actor_ref not in ActorRegistry.get_all()

    ActorRegistry.register(actor_ref)
    assert actor_ref in ActorRegistry.get_all()
github jodal / pykka / tests / test_registry.py View on Github external
def test_all_actors_can_be_stopped_through_registry(a_actor_refs, b_actor_refs):
    assert len(ActorRegistry.get_all()) == 8

    ActorRegistry.stop_all(block=True)

    assert len(ActorRegistry.get_all()) == 0
github jodal / pykka / tests / test_registry.py View on Github external
def test_actor_is_unregistered_when_stopped(actor_ref):
    assert actor_ref in ActorRegistry.get_all()

    actor_ref.stop()

    assert actor_ref not in ActorRegistry.get_all()
github jodal / pykka / tests / test_registry.py View on Github external
def test_actor_is_registered_when_started(actor_ref):
    assert actor_ref in ActorRegistry.get_all()
github mopidy / mopidy / mopidy / internal / process.py View on Github external
def stop_remaining_actors():
    num_actors = len(pykka.ActorRegistry.get_all())
    while num_actors:
        logger.error(
            'There are actor threads still running, this is probably a bug')
        logger.debug(
            '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('Stopping %d actor(s)...', num_actors)
        pykka.ActorRegistry.stop_all()
        num_actors = len(pykka.ActorRegistry.get_all())
    logger.debug('All actors stopped.')