Skip to content

Commit

Permalink
Actual good keyboard interrupt
Browse files Browse the repository at this point in the history
- Forgot that I actually need to kill the threads before joining them, else they will complete the queue.
- Made the KeyboardInterrupt definitely work properly now >∆∆<
  • Loading branch information
dzuk-mutant committed Sep 27, 2019
1 parent 0fec628 commit 32bcf27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 7 additions & 4 deletions export.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,18 @@ def export(m, filtered_emoji, input_path, formats, path, src_size,
log.bar.finish()


except KeyboardInterrupt:
except (KeyboardInterrupt, SystemExit):
# make sure all those threads are tidied before exiting the program.
# also make sure the bar is finished so it doesnt eat the cursor.
log.bar.finish()
log.out('>∆∆< Cancelled!', 93)
log.out('Stopping threads and tidying up...', 93)

log.out(f'Stopping threads and tidying up...', 93)
if threads:
for t in threads:
t.kill()
t.join()

raise


log.out('- done!', 32)
if log.filtered_export_task_count > 0:
Expand Down
12 changes: 6 additions & 6 deletions orxport.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def main():
emoji_filter = []
emoji_filter_text = "" # for error messaging only
json_out = None
web_out = None
json_web_out = None
src_size = None
num_threads = DEF_NUM_THREADS
force_desc = False
Expand Down Expand Up @@ -124,7 +124,7 @@ def main():
elif opt == '-j':
json_out = arg
elif opt == '-J':
web_out = arg
json_web_out = arg
elif opt == '-q':
t1, t2 = arg.split('x')
src_size = int(t1), int(t2)
Expand Down Expand Up @@ -179,15 +179,15 @@ def main():
# JSON out or image out
if json_out:
jsonutils.write_emoji(filtered_emoji, json_out)
elif web_out:
jsonutils.write_web(filtered_emoji, web_out)
elif json_web_out:
jsonutils.write_web(filtered_emoji, json_web_out)
else:
export.export(m, filtered_emoji, input_path, output_formats,
os.path.join(output_path, output_naming), src_size,
num_threads, renderer, max_batch, verbose)

except KeyboardInterrupt as e:
log.out(f'\n>∆∆< Cancelled!\n{e}', 93)
except (KeyboardInterrupt, SystemExit) as e:
log.out(f'>∆∆< Cancelled!\n{e}', 93)
sys.exit(1)

# Where all the exceptions eventually go~
Expand Down

0 comments on commit 32bcf27

Please sign in to comment.