Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rendercanvas/_coreutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


IS_WIN = sys.platform.startswith("win") # Note that IS_WIN is false on Pyodide
IS_PYODIDE = sys.platform == "emscripten"


# %% Logging
Expand Down
10 changes: 9 additions & 1 deletion rendercanvas/utils/asyncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import sys

from .._coreutils import IS_WIN, call_later_from_thread
from .._coreutils import IS_WIN, IS_PYODIDE, call_later_from_thread


USE_THREADED_TIMER = IS_WIN
Expand All @@ -24,6 +24,10 @@

def detect_current_async_lib():
"""Get the lib name of the currently active async lib, or None."""

if IS_PYODIDE:
return "asyncio"

ob = sys.get_asyncgen_hooks()[0]
if ob is not None:
try:
Expand All @@ -40,6 +44,10 @@ def detect_current_async_lib():
def detect_current_call_soon_threadsafe():
"""Get the current applicable call_soon_threadsafe function, or None"""

# We could support Pyodide too, but this never gets called on Pyodide anyway (bc USE_THREADED_TIMER). Leaving commented for reference.
# if IS_PYODIDE:
# return sys.modules["asyncio"].get_running_loop().call_soon_threadsafe

# Get asyncgen hook func, return fast when no async loop active
ob = sys.get_asyncgen_hooks()[0]
if ob is None:
Expand Down
Empty file added tests/test_glfw.py
Empty file.
4 changes: 2 additions & 2 deletions tests/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def _test_scheduling_continuous(canvas):

# And a second one after 0.1s, with 10 fps.
canvas.active_sleep(0.1)
assert canvas.draw_count == 2
assert canvas.events_count == 2
assert canvas.draw_count in (2, 3)
assert canvas.events_count in (2, 3)

# And after one second, about 10 more
canvas.draw_count = canvas.events_count = 0
Expand Down