utils.asyncs
This module implements all async functionality that one can use in any rendercanvas backend.
To give an idea how to implement a generic async sleep function:
libname = detect_current_async_lib()
sleep = sys.modules[libname].sleep
- class rendercanvas.utils.asyncs.Event
Generic async event object. Works with trio, asyncio and rendercanvas-native.
- rendercanvas.utils.asyncs.detect_current_async_lib()
Get the lib name of the currently active async lib, or None.
- rendercanvas.utils.asyncs.detect_current_call_soon_threadsafe()
Get the current applicable call_soon_threadsafe function, or None
- async rendercanvas.utils.asyncs.precise_sleep(delay)
Generic async sleep that is precise. Works with trio, asyncio and rendercanvas-native.
On Windows, OS timers are notoriously imprecise, with a resolution of 15.625 ms (64 ticks per second). This function, when on Windows, uses a thread to sleep with a much better precision.
- async rendercanvas.utils.asyncs.sleep(delay)
Generic async sleep. Works with trio, asyncio and rendercanvas-native.