Skip to content

Commit

Permalink
cherry pick f41a534 (pytorch#2889)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCaoG authored Apr 16, 2021
1 parent 3bca2d7 commit ef3cad0
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit ef3cad0

Please sign in to comment.