MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / async_fn

Function async_fn

tests/python/test_event_loop.py:7–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6def test_setTimeout_unref():
7 async def async_fn():
8 obj = {'val': 0}
9 pm.eval("""(obj) => {
10 setTimeout(()=>{ obj.val = 2 }, 1000).ref().ref().unref().ref().unref().unref();
11 // chaining, no use on the first two ref calls since it's already refed initially
12 setTimeout(()=>{ obj.val = 1 }, 100);
13 }""")(obj)
14 await pm.wait() # we shouldn't wait until the first timer is fired since it's currently unrefed
15 assert obj['val'] == 1
16
17 # making sure the async_fn is run
18 return True
19 assert asyncio.run(async_fn())
20
21

Callers 9

test_setTimeout_unrefFunction · 0.70
test_setInterval_unrefFunction · 0.70
test_clearIntervalFunction · 0.70
test_finished_timer_refFunction · 0.70
test_set_clear_timeoutFunction · 0.70
test_promisesFunction · 0.70
test_webassemblyFunction · 0.70

Calls 4

coro_fnFunction · 0.85
coro_to_throw0Function · 0.85
coro_to_throw1Function · 0.85
cFunction · 0.70

Tested by

no test coverage detected