gvalkov / python-evdev

Python bindings for the Linux input subsystem
https://python-evdev.rtfd.org/
BSD 3-Clause "New" or "Revised" License
336 stars 112 forks source link

evdev/eventio_async.py: python3.11 compatibility #174

Closed Nowa-Ammerlaan closed 2 years ago

Nowa-Ammerlaan commented 2 years ago

From the Python 3.11 Changelog:

The @asyncio.coroutine decorator enabling legacy generator-based coroutines to be compatible with async/await code. The function has been deprecated since Python 3.8 and the removal was initially scheduled for Python 3.10. Use async def instead. (Contributed by Illia Volochii in bpo-43216.)

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

sezanzeb commented 2 years ago

I'll look into this soon, thanks

sezanzeb commented 2 years ago

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