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())
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())
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()))
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))