Skip to content

Commit

Permalink
add some comment
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten23 committed Feb 8, 2024
1 parent 6c9277f commit e89769d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion torch_xla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ def _setup_tpu_vm_library_path() -> bool:

def _prepare_to_exit():
try:
raise ValueError('fake error')
_XLAC._prepare_to_exit()
if int(os.environ.get('PT_XLA_DEBUG', '0')):
_summarize_fn_tracker()
except Exception as e:
logging.error(
"Caught an exception when exiting the process. Exception: ", exc_info=e)
os._exit(1)
# Due to https://bugs.python.org/issue27035, simply raising an exception in the atexit callback does not set the exit code correctly. That is why we need to set the exit code explicitly.
# Using `exit(1)` does not set a correct exit code because it is useful for the interactive interpreter shell and should not be used in programs and it works by raising an exception. (https://docs.python.org/3/library/constants.html#exit)
# sys.exit(1) does not set a correct exit code because it also raises an exception.
exit(1)


def _init_xla_lazy_backend():
Expand Down

0 comments on commit e89769d

Please sign in to comment.