Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jul 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions evdev/eventio_async.py
Expand Up @@ -85,8 +85,7 @@ def __next__(self):
def __aiter__(self):
return self

@asyncio.coroutine
def __anext__(self):
async def __anext__(self):
Copy link

@jonasBoss jonasBoss Jul 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. I think this is the correct solution indeed. Will release a new version asap. Thanks!

future = asyncio.Future()
try:
# Read from the previous batch of events.
Expand Down