File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919
2020
2121IS_WIN = sys .platform .startswith ("win" ) # Note that IS_WIN is false on Pyodide
22+ IS_PYODIDE = sys .platform == "emscripten"
2223
2324
2425# %% Logging
Original file line number Diff line number Diff line change 1212
1313import sys
1414
15- from .._coreutils import IS_WIN , call_later_from_thread
15+ from .._coreutils import IS_WIN , IS_PYODIDE , call_later_from_thread
1616
1717
1818USE_THREADED_TIMER = IS_WIN
2424
2525def detect_current_async_lib ():
2626 """Get the lib name of the currently active async lib, or None."""
27+
28+ if IS_PYODIDE :
29+ return "asyncio"
30+
2731 ob = sys .get_asyncgen_hooks ()[0 ]
2832 if ob is not None :
2933 try :
@@ -40,6 +44,10 @@ def detect_current_async_lib():
4044def detect_current_call_soon_threadsafe ():
4145 """Get the current applicable call_soon_threadsafe function, or None"""
4246
47+ # We could support Pyodide too, but this never gets called on Pyodide anyway (bc USE_THREADED_TIMER). Leaving commented for reference.
48+ # if IS_PYODIDE:
49+ # return sys.modules["asyncio"].get_running_loop().call_soon_threadsafe
50+
4351 # Get asyncgen hook func, return fast when no async loop active
4452 ob = sys .get_asyncgen_hooks ()[0 ]
4553 if ob is None :
Original file line number Diff line number Diff line change @@ -147,8 +147,8 @@ def _test_scheduling_continuous(canvas):
147147
148148 # And a second one after 0.1s, with 10 fps.
149149 canvas .active_sleep (0.1 )
150- assert canvas .draw_count == 2
151- assert canvas .events_count == 2
150+ assert canvas .draw_count in ( 2 , 3 )
151+ assert canvas .events_count in ( 2 , 3 )
152152
153153 # And after one second, about 10 more
154154 canvas .draw_count = canvas .events_count = 0
You can’t perform that action at this time.
0 commit comments