Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52794

Re: Raw_input with readline in a daemon thread makes terminal text disappear

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <david.m.welch@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:text': 0.05; 'url:pipermail': 0.05; '(python': 0.07; 'executes': 0.09; 'exit': 0.09; 'creates': 0.14; 'thread': 0.14; 'backspace': 0.16; 'invisible': 0.16; 'mode,': 0.16; 'ssh': 0.16; 'subject: \n ': 0.16; 'suspects': 0.16; 'thread,': 0.16; 'url:2009-october': 0.16; 'url:unix': 0.16; 'thanks,': 0.17; 'all,': 0.19; 'module': 0.19; 'command': 0.22; 'input': 0.22; 'import': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'text,': 0.24; 'visible': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'wondering': 0.29; 'appreciated.': 0.29; "i'm": 0.30; 'program,': 0.31; 'code': 0.31; 'getting': 0.31; '(although': 0.31; 'loading': 0.31; 'run': 0.32; 'open': 0.33; 'url:python': 0.33; 'running': 0.33; 'minimal': 0.33; 'not.': 0.33; 'screen': 0.34; 'skip:d 20': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'header:Mime-version:1': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'two': 0.37; 'loss': 0.38; 'message-id:@gmail.com': 0.38; 'thank': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; '(from': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'dave': 0.60; 'new': 0.61; 'john': 0.61; 'simple': 0.61; 'back': 0.62; 'real': 0.63; 'such': 0.63; 'more': 0.64; 'forward': 0.65; 'here': 0.66; 'close': 0.67; 'results': 0.69; 'prime': 0.74; 'behavior': 0.77
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:date:subject:from:to:cc:message-id:thread-topic :mime-version:content-type; bh=y0xUJB/SEejht/ZY6C/7v/FdWZJINccNE/JldgaL3p0=; b=MC+CqRrsdp0nrmQcsw23ibExPKVdQhLi/LN8xfXIaV4twOMaAUtsX57yJ0cgAHv0Pf jEC1hs/mpKULCtMFk6lXdvoWJ45G3iZmia0Yy8L1y6/s8JZ2gZORoSmEZ2alk5hwuuxl atrwj3n4XTVWqDTJktvcoXuezLp+/j2IQorD6cYZKTVCIvi1FMtPXQ62o7b/IYnbJNZe YMNvd5tIynjPKmPrMARfEJSp39sHVyc8qzaYNuvzKfvsRRjWwizjk6K2aIHQejanK3JV vXYoC5nkx2mPo6WoEcpjh9KF/pgSMKaF8oPsCheoZUS+Uz49Tx04cJmqEqImVSoYomrf yvDg==
X-Received by 10.50.3.3 with SMTP id 3mr991747igy.54.1377103340222; Wed, 21 Aug 2013 09:42:20 -0700 (PDT)
User-Agent Microsoft-MacOutlook/14.3.6.130613
Date Wed, 21 Aug 2013 11:42:11 -0500
Subject Re: Raw_input with readline in a daemon thread makes terminal text disappear
From "David M. Welch" <david.m.welch@gmail.com>
To <python-list@python.org>
Thread-Topic Raw_input with readline in a daemon thread makes terminal text disappear
Mime-version 1.0
Content-type multipart/alternative; boundary="B_3459930138_10254387"
X-Mailman-Approved-At Wed, 21 Aug 2013 22:47:30 +0200
Cc research@johnohagan.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.104.1377118050.19984.python-list@python.org> (permalink)
Lines 125
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377118050 news.xs4all.nl 15943 [2001:888:2000:d::a6]:47106
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52794

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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.

Thank you,
Dave W.
Response to post: 
http://mail.python.org/pipermail/python-list/2009-October/554784.html
I'm getting input for a program while it's running by using raw_input in a
loop in separate thread. This works except for the inconvenience of not
having 
a command history or the use of backspace etc.

That can be solved by loading the readline module; however, it results in a
loss of visible access to the terminal when the program ends: nothing is
echoed to the screen and the history is invisible (although it is there -
hitting return executes whatever should be there normally). The only way to
get it back is to close the terminal and open a new one.

Here is minimal code that reproduces the problem (python 2.5 on Linux):

from threading import Thread
import readline

get_input = Thread(target=raw_input)
get_input.setDaemon(True)
get_input.start()

If the thread is not set to daemon mode, there is no such problem (don't
know 
why this makes a difference), but in the real program, it needs to be a
daemon 
or it hangs the exit waiting for more input.

Any suggestions appreciated.

Thanks,

John


Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Raw_input with readline in a daemon thread makes terminal text disappear "David M. Welch" <david.m.welch@gmail.com> - 2013-08-21 11:42 -0500

csiph-web