From 31cea814977c32b02bf9166cf4490f70e9861d1c Mon Sep 17 00:00:00 2001 From: Thomas Ballinger Date: Thu, 16 Oct 2014 21:36:20 -0400 Subject: Add Python 2 compatibility --- termcast_client/pity.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'termcast_client/pity.py') diff --git a/termcast_client/pity.py b/termcast_client/pity.py index 26a9e49..966c793 100644 --- a/termcast_client/pity.py +++ b/termcast_client/pity.py @@ -1,3 +1,4 @@ +import errno import fcntl import os import pty @@ -5,6 +6,8 @@ import signal import termios import tty +from . import py2compat + CHILD = pty.CHILD STDIN_FILENO = pty.STDIN_FILENO STDOUT_FILENO = pty.STDOUT_FILENO @@ -68,9 +71,9 @@ def spawn(argv, master_read=pty._read, stdin_read=pty._read, handle_window_size= while True: try: pty._copy(master_fd, master_read, stdin_read) - except InterruptedError: - continue - except OSError: + except OSError as e: + if e.errno == errno.EINTR: + continue if restore: tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) break -- cgit v1.2.3