Пример #1
0
def wait_for_stop(test, aid, terminating=False):
    '''Wait for an actor to stop'''
    arbiter = pulsar.arbiter()
    waiter = pulsar.Future(loop=arbiter._loop)

    def remove():
        test.assertEqual(arbiter.remove_callback('periodic_task', check), 1)
        waiter.set_result(None)

    def check(caller, **kw):
        test.assertEqual(caller, arbiter)
        if not terminating:
            test.assertFalse(aid in arbiter.managed_actors)
        elif aid in arbiter.managed_actors:
            return
        arbiter._loop.call_soon(remove)

    arbiter.bind_event('periodic_task', check)
    return waiter
Пример #2
0
 def post_async(self, request):
     future = pulsar.Future()
     future._loop.call_later(0.5, lambda: future.set_result(['Hello!']))
     return future