Describe the bug
If an async callback registered with set_key_callback_async() throws an exception -- even a runtime exception -- the error is silently swallowed. (This applies to other async callback types as well, eg. dial callbacks.) This skips any asyncio exception handler that may have been registered. As you can imagine this can be quite confusing because a little typo or whatever causes strange silent failure.
This is because the line where the callback is dispatched to the event loop discards the resulting Future:
|
asyncio.run_coroutine_threadsafe(async_callback(*args), loop) |
This could be fixed by taking the result of loop.run_coroutine_threadsafe and then calling .add_done_callback() on it to log or otherwise handle the error, OR, by using loop.call_soon_threadsafe instead and having it use loop.create_task to invoke the callback (the Task will use the system exception reporting as usual).
To Reproduce
Register an async callback that raises an exception of any type. Run the program, see no errors -- it just keeps running, and the callback in question silently stops at the point of error.
StreamDeck Information
(Applies to all StreamDeck models.)
System Information
(Applies to all OS. I am using library 0.9.8 and it seems to be the case at github head as well.)
Describe the bug
If an async callback registered with
set_key_callback_async()throws an exception -- even a runtime exception -- the error is silently swallowed. (This applies to other async callback types as well, eg. dial callbacks.) This skips any asyncio exception handler that may have been registered. As you can imagine this can be quite confusing because a little typo or whatever causes strange silent failure.This is because the line where the callback is dispatched to the event loop discards the resulting
Future:python-elgato-streamdeck/src/StreamDeck/Devices/StreamDeck.py
Line 477 in 47c97ad
This could be fixed by taking the result of
loop.run_coroutine_threadsafeand then calling.add_done_callback()on it to log or otherwise handle the error, OR, by usingloop.call_soon_threadsafeinstead and having it useloop.create_taskto invoke the callback (the Task will use the system exception reporting as usual).To Reproduce
Register an async callback that raises an exception of any type. Run the program, see no errors -- it just keeps running, and the callback in question silently stops at the point of error.
StreamDeck Information
(Applies to all StreamDeck models.)
System Information
(Applies to all OS. I am using library 0.9.8 and it seems to be the case at github head as well.)