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

How to answer a prompt from a different thread / task? #1914

Open
fra-luc opened this issue Sep 12, 2024 · 0 comments
Open

How to answer a prompt from a different thread / task? #1914

fra-luc opened this issue Sep 12, 2024 · 0 comments

Comments

@fra-luc
Copy link

fra-luc commented Sep 12, 2024

Hello and thanks for this cool library!

Given this example

from prompt_toolkit import prompt

def main():
    text = prompt('> ')
    print('You entered:', text)

if __name__ == '__main__':
    main()

How would I answer the prompt programmatically from a different thread or asyncio task?
I digged up a bit and it looks like under the hood prompt calls asyncio.run(coro) where coro is an internal coroutine that reacts to key pressure in the terminal.

There is a way to get that coroutine and maybe stop it or change its status?
Or maybe some trick to fake keyboard pressure?

Thanks!

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

No branches or pull requests

1 participant