File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 22import pythonmonkey as pm
33import asyncio
44
5- def test_timers_unref ():
5+ def test_setTimeout_unref ():
66 async def async_fn ():
77 obj = {'val' : 0 }
88 pm .eval ("""(obj) => {
@@ -17,6 +17,18 @@ async def async_fn():
1717 return True
1818 assert asyncio .run (async_fn ())
1919
20+ def test_setInterval_unref ():
21+ async def async_fn ():
22+ obj = {'val' : 0 }
23+ pm .eval ("""(obj) => {
24+ setInterval(()=>{ obj.val++ }, 200).unref()
25+ setTimeout(()=>{ }, 500)
26+ }""" )(obj )
27+ await pm .wait () # It should stop after the setTimeout timer's 500ms.
28+ assert obj ['val' ] == 2 # The setInterval timer should only run twice (500 // 200 == 2)
29+ return True
30+ assert asyncio .run (async_fn ())
31+
2032def test_finished_timer_ref ():
2133 async def async_fn ():
2234 # Making sure the event-loop won't be activated again when a finished timer gets re-refed.
You can’t perform that action at this time.
0 commit comments