From d1e0fd23759be74cee7742e2c918a5f04bb6d148 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 28 Apr 2019 10:30:16 +0200 Subject: [PATCH] UnixConsole.restore: fix/ignore restoring of signal in thread (#6) --- pyrepl/unix_console.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py index 1aded8c..a7e311f 100644 --- a/pyrepl/unix_console.py +++ b/pyrepl/unix_console.py @@ -392,8 +392,12 @@ def restore(self): tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate) if hasattr(self, 'old_sigwinch'): - signal.signal(signal.SIGWINCH, self.old_sigwinch) - del self.old_sigwinch + try: + signal.signal(signal.SIGWINCH, self.old_sigwinch) + del self.old_sigwinch + except ValueError: + # signal only works in main thread. + pass def __sigwinch(self, signum, frame): self.height, self.width = self.getheightwidth()