Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _play(self, asciicast, idle_time_limit, speed, stdin):
idle_time_limit = idle_time_limit or asciicast.idle_time_limit
stdout = asciicast.stdout_events()
stdout = ev.to_relative_time(stdout)
stdout = ev.cap_relative_time(stdout, idle_time_limit)
stdout = ev.to_absolute_time(stdout)
stdout = ev.adjust_speed(stdout, speed)
base_time = time.time()
ctrl_c = False
paused = False
pause_time = None
for t, _type, text in stdout:
delay = t - (time.time() - base_time)
while stdin and not ctrl_c and delay > 0:
if paused:
while True:
data = read_blocking(stdin.fileno(), 1000)
if 0x03 in data: # ctrl-c
ctrl_c = True