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

Interactive Example with Asynchronous console input #5

Open
MiMiMeowMeow opened this issue Aug 23, 2019 · 3 comments
Open

Interactive Example with Asynchronous console input #5

MiMiMeowMeow opened this issue Aug 23, 2019 · 3 comments

Comments

@MiMiMeowMeow
Copy link

First of all, great work porting over QP to Python.

I was trying to make an interactive program similar to hsm_test.py but the TimeEvent's don't seem to work. I'm guessing that input('\tEvent --> ') call is blocking and those events are never processed.
I saw that this project has an asynchronous equivalent to input.
https://github.com/vxgmichel/aioconsole

I'm pretty new to Asynchronous programming so I'm wondering if someone would post an example using this package so I can get interactivity with the TimeEvents.

Thanks!

@dwhall
Copy link
Owner

dwhall commented Aug 23, 2019

You're right that input() blocks and it doesn't return anything until you hit enter. So it can't be used to, say, respond to a keypress.

I tried to create such an app once using curses and then urwid... but it never worked quite right.

I'll keep my eye out if there's something new (in asyncio since I last tried) that will help.

@dwhall
Copy link
Owner

dwhall commented Aug 24, 2019

Oh, I just realized that the examples/udp_server.py is one way to do it. This example uses line input (not an event for each keypress like I was talking about above) and TimeEvents. The example requires running the server in one console and the client in another. Assuming Mac OS or Linux, netcat (nc) is the easiest way to have console line input transmitted via UDP to the server. I don't know of a good client for windows; though a basic telnet should do.

@MiMiMeowMeow
Copy link
Author

Ahh.. yes, that should work! Thanks for your help!

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

2 participants