Skip to content

Conversation

@almarklein
Copy link
Member

@almarklein almarklein commented Oct 21, 2025

This PR removes support for event handlers that are coroutines (i.e. async functions).

This functionality was initially introduced to allow using async wgpu methods in callbacks. However, in hindsight it does not fit well, and it also prevents handling events inside the native draw event, which causes problem on its own (see e.g. #56).

With pygfx/wgpu-py#739, users have options to handle async methods using callbacks (using promise.then().

So to summarize: disallowing async functions, means that emit() and other methods of the event emitter can now be sync, which means they can be called anywhere, which we need to create a congruent event loop.

(I have more changes to the scheduling planned, to allow asynchronous bitmap presenting, and this change will help in that work.)

Although this is a breaking API change, I doubt that anyone is actually using this coroutines as callbacks.

@almarklein almarklein requested a review from Korijn October 22, 2025 12:22
@almarklein almarklein merged commit 9e25c73 into main Oct 22, 2025
12 checks passed
@almarklein almarklein deleted the events-no-async branch October 22, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants