Raw_input with readline in a daemon thread makes terminal text disappear

random832 at fastmail.us random832 at fastmail.us
Wed Aug 21 17:27:23 EDT 2013


On Wed, Aug 21, 2013, at 12:42, David M. Welch wrote:
> Hi all, 
> 
> This is an old thread, but I'm having the same behavior in my terminal
> when
> I run some code but kill the process in the terminal (Ctrl-C).  The code
> has
> two prime suspects (from a simple google search):
> 1. Creates ssh port forward via the subprocess module
> (http://unix.stackexchange.com/questions/4740/screen-remote-login-failure-an
> d-disappearing-text)
> 2. Using the getpass module (raw_input?)
> Calling "$ reset" brings back the disappearing text, so I'm just
> wondering
> if this issue has been addressed and if so, what should I be doing that
> I'm
> not.

Do you understand how tty modes (in particular, echo vs non-echo mode)
work?

What you've got is two different pieces of code (I think running
readline in two threads qualifies) fighting over the tty mode, and
probably one of them is turning echo mode off and then either never
restoring it because of how the program exits, or it gets into the
other's idea of the "original" mode.

Why does your program design require input to be handled in a thread
other than the main thread?



More information about the Python-list mailing list