Skip to content

Commit

Permalink
Fix unlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelczer committed Jul 29, 2022
1 parent fc25128 commit 8ab5de6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions great_ai/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ def serve() -> None:

finally:
if args.file_name.endswith(".ipynb"):
Path(get_script_name_of_notebook(args.file_name)).unlink(
missing_ok=True
)
try:
Path(get_script_name_of_notebook(args.file_name)).unlink(
missing_ok=True
)
except FileNotFoundError:
# missing_ok only exists >= Python 3.8
pass
else:

class EventHandler(PatternMatchingEventHandler):
Expand Down Expand Up @@ -124,9 +128,13 @@ def stop_server(self) -> None:
observer.stop()
restart_handler.stop_server()
if args.file_name.endswith(".ipynb"):
Path(get_script_name_of_notebook(args.file_name)).unlink(
missing_ok=True
)
try:
Path(get_script_name_of_notebook(args.file_name)).unlink(
missing_ok=True
)
except FileNotFoundError:
# missing_ok only exists >= Python 3.8
pass
observer.join()


Expand Down

0 comments on commit 8ab5de6

Please sign in to comment.