Fix unlinks

This commit is contained in:
Andras Schmelczer 2022-07-29 13:20:14 +02:00
parent fc251281a8
commit 8ab5de6b19
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E

View file

@ -76,9 +76,13 @@ def serve() -> None:
finally: finally:
if args.file_name.endswith(".ipynb"): if args.file_name.endswith(".ipynb"):
Path(get_script_name_of_notebook(args.file_name)).unlink( try:
missing_ok=True Path(get_script_name_of_notebook(args.file_name)).unlink(
) missing_ok=True
)
except FileNotFoundError:
# missing_ok only exists >= Python 3.8
pass
else: else:
class EventHandler(PatternMatchingEventHandler): class EventHandler(PatternMatchingEventHandler):
@ -124,9 +128,13 @@ def serve() -> None:
observer.stop() observer.stop()
restart_handler.stop_server() restart_handler.stop_server()
if args.file_name.endswith(".ipynb"): if args.file_name.endswith(".ipynb"):
Path(get_script_name_of_notebook(args.file_name)).unlink( try:
missing_ok=True 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() observer.join()