Skip to content

Add async def wait to EventQueue objects #6705

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

Closed
wants to merge 2 commits into from

Conversation

jepler
Copy link

@jepler jepler commented Aug 6, 2022

In conjunction with adafruit/Adafruit_CircuitPython_asyncio#25 this allows keypad-using code to await the presence of a new event:

async def aget(scanner):
    await scanner.events.wait()
    return scanner.events.get()

async def keeb(pin):
    with keypad.Keys((pin,), value_when_pressed=False) as kb:
        while True:
            print(await aget(kb))

Aside from other issues (it'd be nicer to not need the aget function at all but be able to await kb.events.aget(), it's also a bit weird for built in functionality to rely on code in an .py module.

jepler added 2 commits August 6, 2022 11:06
This is needed so that asyncio.event.ThreadSafeFlag can be used.
@jepler
Copy link
Author

jepler commented Aug 8, 2022

I think #6712 is probably a better way forward.

@jepler jepler closed this Aug 8, 2022
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.

1 participant