evdev/eventio_async.py: python3.11 compatibility - #174
Conversation
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
|
I'll look into this soon, thanks |
|
This doesn't work anymore with your change in Python 3.10.4: import evdev
import asyncio
async def main():
keyboard = evdev.InputDevice("/dev/input/event7")
async for event in keyboard.async_read_loop():
print(event.type, event.code, event.value)
loop = asyncio.new_event_loop()
loop.run_until_complete(main())python-evdev tests are very rudimentary afaik. I found this by running input-remappers tests |
|
|
||
| @asyncio.coroutine | ||
| def __anext__(self): | ||
| async def __anext__(self): |
There was a problem hiding this comment.
according to the python docs __anext__ should return a Awaitable which this function already does. So there is no need to use the async keyword. async def would wrap the whole function again inside a awaitable making it necessary to await this function twice.
| async def __anext__(self): | |
| def __anext__(self): |
As for the @asyncio.coroutine: I think this was never needed as it was meant for generator-based coroutines which this function is not.
I did some quick tests with python3.8 and 3.10. This seems to work fine.
There was a problem hiding this comment.
Hi. I think this is the correct solution indeed. Will release a new version asap. Thanks!
From the Python 3.11 Changelog:
This small change should make things work with python 3.11, the tests are passing for me.
Signed-off-by: Andrew Ammerlaan andrewammerlaan@gentoo.org