Skip to content

Commit

Permalink
Refactor KeyboardInterrupt handling in predict.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonjchen committed Jul 2, 2024
1 parent 4823566 commit 65887e6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,16 @@ def predict(
if proc_output:
print(proc_output)
except KeyboardInterrupt:
process.kill()
try:
process.kill()
except Exception as e:
print(f"Failed to kill the process: {e}")
try:
subprocess.run(["tmux", "kill-session", "-t", "clipper"], check=True)
except subprocess.CalledProcessError as e:
print(f"Failed to kill the tmux session 'clipper': {e}")
except Exception as e:
print(f"An error occurred while trying to kill the tmux session 'clipper': {e}")
raise

return Path("./shared/cog-clip.mp4")
Expand Down

0 comments on commit 65887e6

Please sign in to comment.