Skip to content

Commit ef3cad0

Browse files
authored
cherry pick f41a534 (#2889)
1 parent 3bca2d7 commit ef3cad0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

torch_xla/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414

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

2022

2123
def _maybe_select_tpu_version():

0 commit comments

Comments
 (0)