Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions torch_xla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@


def server_is_alive():
return len(
subprocess.Popen(['pgrep', '-f', XRT_SERVER_REGEX],
stdout=subprocess.PIPE).stdout.readline()) != 0
# pgrep returns 0 when at least one running process matches the requested name.
# Otherwise, the exit code is 1. If pgrep is not availiable in the system, it
# will return an exit code 127.
return subprocess.getstatusoutput(
'pgrep -f "{}"'.format(XRT_SERVER_REGEX))[0] == 0


def _maybe_select_tpu_version():
Expand Down