Skip to content

Commit

Permalink
Fix issue LazoCoder#197: Ctrl+C interrupt no longer causes Traceback …
Browse files Browse the repository at this point in the history
…error when slideshow is cleared.
  • Loading branch information
CullenLYe committed Apr 3, 2024
1 parent ed8f7f4 commit 0876eb0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pokemonterminal/slideshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ def __get_listener_thread(event):

def __slideshow_worker(filtered, delay, changer_func, event_name):
with PlatformNamedEvent(event_name) as e:
t = __get_listener_thread(e)
random.shuffle(filtered)
queque = iter(filtered)
while t.is_alive():
next_pkmn = next(queque, None)
if next_pkmn is None:
random.shuffle(filtered)
queque = iter(filtered)
continue
changer_func(next_pkmn.get_path())
t.join(delay * 60)
try:
t = __get_listener_thread(e)
random.shuffle(filtered)
queque = iter(filtered)
while t.is_alive():
next_pkmn = next(queque, None)
if next_pkmn is None:
random.shuffle(filtered)
queque = iter(filtered)
continue
changer_func(next_pkmn.get_path())
t.join(delay * 60)
except KeyboardInterrupt:
pass

def start(filtered, delay, changer_func, event_name):
p = multiprocessing.Process(target=__slideshow_worker, args=(filtered, delay, changer_func, event_name, ), daemon=True)
Expand Down

0 comments on commit 0876eb0

Please sign in to comment.