Skip to content

Commit

Permalink
Add workaround to make sure echo is enabled after reload (refs Pylons…
Browse files Browse the repository at this point in the history
…#689)

Also add myself to CONTRIBUTORS.txt
  • Loading branch information
davisagli committed Feb 13, 2015
1 parent 9f46803 commit a1d053c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Next release
============

- Work around an issue where ``pserve --reload`` would leave terminal echo
disabled if it reloaded during a pdb session.
Backported from https://github.com/Pylons/pyramid/pull/1577

- Fixed a failing unittest caused by differing mimetypes on various
OS platforms. See https://github.com/Pylons/pyramid/issues/1405

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,5 @@ Contributors
- Fenton Travers, 2014/05/06

- Geoffrey T. Dairiki, 2015/02/06

- David Glick, 2015/02/12
14 changes: 14 additions & 0 deletions pyramid/scripts/pserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@

MAXFD = 1024

try:
import termios
except ImportError: # pragma: no cover
termios = None

if WIN and not hasattr(os, 'kill'): # pragma: no cover
# py 2.6 on windows
def kill(pid, sig=None):
Expand Down Expand Up @@ -691,6 +696,14 @@ def handle_term(signo, frame):
raise SystemExit
signal.signal(signal.SIGTERM, handle_term)

def ensure_echo_on(): # pragma: no cover
if termios:
fd = sys.stdin.fileno()
attr_list = termios.tcgetattr(fd)
if not attr_list[3] & termios.ECHO:
attr_list[3] |= termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, attr_list)

def install_reloader(poll_interval=1, extra_files=None): # pragma: no cover
"""
Install the reloading monitor.
Expand All @@ -700,6 +713,7 @@ def install_reloader(poll_interval=1, extra_files=None): # pragma: no cover
``raise_keyboard_interrupt`` option creates a unignorable signal
which causes the whole application to shut-down (rudely).
"""
ensure_echo_on()
mon = Monitor(poll_interval=poll_interval)
if extra_files is None:
extra_files = []
Expand Down

0 comments on commit a1d053c

Please sign in to comment.