This commit is contained in:
Colombo 2020-01-22 22:14:31 +04:00
parent 869c5e8dd0
commit f1a3150ce9
6 changed files with 75 additions and 50 deletions

View file

@ -367,6 +367,7 @@ class InteractBase(object):
def input_in_time (self, str, max_time_sec):
sq = multiprocessing.Queue()
p = multiprocessing.Process(target=self.input_process, args=( sys.stdin.fileno(), sq, str))
p.daemon = True
p.start()
t = time.time()
inp = False
@ -380,6 +381,25 @@ class InteractBase(object):
sys.stdin = os.fdopen( sys.stdin.fileno() )
return inp
def input_process_skip_pending(self, stdin_fd):
sys.stdin = os.fdopen(stdin_fd)
while True:
try:
if sys.stdin.isatty():
sys.stdin.read()
except:
pass
def input_skip_pending(self):
"""
skips unnecessary inputs between the dialogs
"""
p = multiprocessing.Process(target=self.input_process_skip_pending, args=( sys.stdin.fileno(), ))
p.daemon = True
p.start()
time.sleep(0.5)
p.terminate()
sys.stdin = os.fdopen( sys.stdin.fileno() )
class InteractDesktop(InteractBase):