示例#1
0
def outer_async():
    """Test that we get the correct active task from the scheduler.

    Even when the execution of one task gets interrupted by a synchonous call to another async
    function, the scheduler retains the correct active task.

    """
    active_task = scheduler.get_active_task()
    inner_async()
    assert_is(active_task, scheduler.get_active_task())
示例#2
0
def test_acached_per_instance_exception_handling():
    obj = AsyncObject()
    try:
        obj.raises_exception()
    except AssertionError:
        # the exception should not affect the internals of the scheduler, and the active task
        # should get cleaned up
        assert_is(None, scheduler.get_active_task())
示例#3
0
    def fn():
        task = scheduler.get_active_task()
        ctx0 = Ctx(0)
        ctx1 = Ctx(1)
        ctx2 = Ctx(0)
        with ctx0:
            with ctx1:
                with ctx2:
                    assert_eq([ctx0, ctx1, ctx2],
                              list(task._contexts.values()))

                assert_eq([ctx0, ctx1], list(task._contexts.values()))
示例#4
0
 def fn():
     task = scheduler.get_active_task()
     assert_eq(0, len(task._dependencies))
     yield [inner_fn.asynq() for _ in range(10)]
     assert_eq(0, len(task._dependencies))