File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
13
13
class Shell (Machine ):
14
+ def bind_context (self , context ):
15
+ super ().bind_context (context )
16
+ self ._has_ps = None
17
+
14
18
def gen_script (self , job ):
15
19
shell_script = super ().gen_script (job )
16
20
return shell_script
@@ -72,6 +76,15 @@ def check_status(self, job):
72
76
if job_id == "" :
73
77
return JobStatus .unsubmitted
74
78
79
+ if self ._has_ps is None :
80
+ ret , stdin , stdout , stderr = self .context .block_call ("which ps" )
81
+ if ret != 0 :
82
+ err_str = stderr .read ().decode ("utf-8" )
83
+ raise RuntimeError (
84
+ "ps command is not found. Consider installing it using `apt-get install procps` or `yum install procps`\n error message:%s\n return code %d\n "
85
+ % (err_str , ret )
86
+ )
87
+ self ._has_ps = True
75
88
# mark defunct process as terminated
76
89
ret , stdin , stdout , stderr = self .context .block_call (
77
90
f"if ps -p { job_id } > /dev/null && ! (ps -o command -p { job_id } | grep defunct >/dev/null) ; then echo 1; fi"
You can’t perform that action at this time.
0 commit comments