예제 #1
0
async def run_random_group_test():
    context = RootContext()
    props = Router.new_random_group([context.spawn(my_actor_props),
                                     context.spawn(my_actor_props),
                                     context.spawn(my_actor_props),
                                     context.spawn(my_actor_props)])

    pid = context.spawn(props)
    for i in range(10):
        await context.send(pid, Message('%s' % (i % 4)))
def create_router_with3_routees():
    routee1 = context.spawn(my_actor_props)
    routee2 = context.spawn(my_actor_props)
    routee3 = context.spawn(my_actor_props)

    props = Router.new_random_group([routee1, routee2, routee3],
                                    10000).with_mailbox(MockMailbox)

    router = context.spawn(props)
    return router, routee1, routee2, routee3