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

Terminal input issues after restart during PDB session #689

Closed
Sapphire64 opened this issue Sep 13, 2012 · 8 comments
Closed

Terminal input issues after restart during PDB session #689

Sapphire64 opened this issue Sep 13, 2012 · 8 comments

Comments

@Sapphire64
Copy link
Contributor

Hello again :) I have issues on two of my systems - both amd64 Debian Wheezy with KDE 4.8.4. Both reproducible in python 2.7 and in python 3.2.

Description:
When I'm adding import pdb; pdb.set_trace() into my Pyramid's project code I have possibility to debug it with interactive interpreter. This is very cool, but 2nd or 3rd restart (by ^C or automatically) breaks this cool feature - I can't see nothing what I'm typing in terminal - just blank input line:
"(Pdb) {always blank here} ".
Any input actually works (but somewhat weird), but it does not echo this input in terminal. So I always have to close this terminal window, open new and start ../bin/pserve development.ini again.

To describe more this issue: when I'm typing su in this broken terminal it gives me only a second to type password and then it automatically press 'enter' so system responds with "Wrong password".

This issue easily reproducible on both of my systems, in py2 and py3 pyramid projects, in Konsole, Yakuake and XTerm terminals.

I'm not sure what can it be, maybe not exactly Pyramid bug, but maybe bug of Pyramid's webserver or pdb module itself. Looks like this is not an issue of terminals - even if Konsole & Yakuake are almost the same inside, oldschool XTerm quite differs from them. Maybe I should try to reproduce this in system's tty terminal.

@mcdonc
Copy link
Member

mcdonc commented Sep 13, 2012

I dont know how to fix this (I've lived with it for years now) but a workaround is just to always press "c" to continue the program before pressing ctrl-C to exit.

@mmerickel
Copy link
Member

In bash and zsh you can use the "reset" command in the terminal to fix it. You can't see it while you type it, but it works. This is a readline and pdb issue and not related to pyramid.

@tseaver
Copy link
Member

tseaver commented Sep 13, 2012

On 09/13/2012 04:11 PM, Sapphire64 wrote:

Hello again :) I have issues on two of my systems - both amd64 Debian
Wheezy with KDE 4.8.4. Both reproducible in python 2.7 and in python
3.2.

Description: When I'm adding import pdb; pdb.set_trace() into my
Pyramid's project code I have possibility to debug it with interactive
interpreter. This is very cool, but 2nd or 3rd restart (by ^C or
automatically) breaks this cool feature - I can't see nothing what I'm
typing in terminal - just blank input line: "(Pdb) {always blank here}
". Any input actually works (but somewhat weird), but it does not echo
this input in terminal. So I always have to close this terminal window,
open new and start ../bin/pserve development.ini again.

To describe more this issue: when I'm typing su in this broken
terminal it gives me only a second to type password and then it
automatically press 'enter' so system responds with "Wrong password".

This issue easily reproducible on both of my systems, in py2 and py3
pyramid projects, in Konsole, Yakuake and XTerm terminals.

I'm not sure what can it be, maybe not exactly Pyramid bug, but maybe
bug of Pyramid's webserver or pdb module itself. Looks like this is not
an issue of terminals - even if Konsole & Yakuake are almost the same
inside, oldschool XTerm quite differs from them. Maybe I should try to
reproduce this in system's tty terminal.

This is an issue with PDB, not with Pyramid.

@mcdonc
Copy link
Member

mcdonc commented Sep 13, 2012

Some people also use "stty sane"

@Sapphire64
Copy link
Contributor Author

"stty sane" and "reset" works great for me, thanks!

Maybe it will be great to include subprocess.Popen("stty sane") into web server provided with pyramid to execute on each start and restart (for compatible OS and shells ofcource)? Looks like this command's impact on console experience not so destracting, not like when executing "reset". Probably, it is too complicated to implement, but maybe it is possible to handle at least ^C and launch "stty sane" then - after (hopefully) the moment when all breaks.

Anyway, thanks for reply!

@mcdonc
Copy link
Member

mcdonc commented Sep 13, 2012

Unlikely to do that, given how complex terminal emulation can get cross-platform (not to mention on non-UNIX systems). Thanks for the report, though!

@piotr-dobrogost
Copy link

I'm running into this issue, too. Django fixed this - see Runserver reloading breaks terminal STDIN when using pdb.set_trace(). I found this through iPython - “broken” shell/terminal after realoading Django. We could do the same or at least provide some hook fired when server is restarted so that users could hook needed code themselves.

@tseaver
Copy link
Member

tseaver commented Apr 22, 2013

Thanks for the reference, Piotr. FTR, the Django diff referenced as fixing that issue is here:

django/django@f5b22ed997

davisagli added a commit to davisagli/pyramid that referenced this issue Feb 13, 2015
davisagli added a commit to davisagli/pyramid that referenced this issue Feb 13, 2015
mmerickel added a commit that referenced this issue Feb 13, 2015
Backport fix for terminal echo after reload (refs #689)
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

5 participants