File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9999 unicode = str
100100
101101
102+ if sys.version_info >= (3, 4):
103+ def is_main_thread():
104+ return threading.main_thread() == threading.current_thread()
105+ else:
106+ def is_main_thread():
107+ return isinstance(threading.current_thread(), threading._MainThread)
108+
109+
102110class FakeStdin(object):
103111 """The stdin object user code will reference
104112
@@ -533,7 +541,7 @@ def __enter__(self):
533541 self.orig_sigwinch_handler = signal.getsignal(signal.SIGWINCH)
534542 self.orig_sigtstp_handler = signal.getsignal(signal.SIGTSTP)
535543
536- if isinstance(threading.current_thread(), threading._MainThread ):
544+ if is_main_thread( ):
537545 # This turns off resize detection and ctrl-z suspension.
538546 signal.signal(signal.SIGWINCH, self.sigwinch_handler)
539547 signal.signal(signal.SIGTSTP, self.sigtstp_handler)
@@ -550,7 +558,7 @@ def __exit__(self, *args):
550558 sys.stdout = self.orig_stdout
551559 sys.stderr = self.orig_stderr
552560
553- if isinstance(threading.current_thread(), threading._MainThread ):
561+ if is_main_thread( ):
554562 # This turns off resize detection and ctrl-z suspension.
555563 signal.signal(signal.SIGWINCH, self.orig_sigwinch_handler)
556564 signal.signal(signal.SIGTSTP, self.orig_sigtstp_handler)
You can’t perform that action at this time.
0 commit comments