Skip to content

Commit

Permalink
Revert code, don't catch TimeoutExpired inside system_call
Browse files Browse the repository at this point in the history
  • Loading branch information
Icemole committed Jul 3, 2024
1 parent 9467ce0 commit b9a8016
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
7 changes: 2 additions & 5 deletions sisyphus/aws_batch_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ def system_call(self, command, send_to_stdin=None):
logging.debug("shell_cmd: %s" % " ".join(system_command))
if send_to_stdin:
send_to_stdin = send_to_stdin.encode()
try:
p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)
except subprocess.TimeoutExpired:
logging.warning("Timeout expired for command: %s" % " ".join(system_command))
return [], ["TimeoutExpired".encode()], -1

p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)

def fix_output(o):
"""
Expand Down
19 changes: 10 additions & 9 deletions sisyphus/load_sharing_facility_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ def system_call(self, command, send_to_stdin=None):
logging.debug("shell_cmd: %s" % " ".join(system_command))
if send_to_stdin:
send_to_stdin = send_to_stdin.encode()
try:
p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(system_command))
return [], ["TimeoutExpired".encode()], -1

p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)

def fix_output(o):
# split output and drop last empty line
Expand Down Expand Up @@ -189,8 +186,10 @@ def submit_helper(self, call, logpath, rqmt, name, task_name, rangestring):
while True:
logging.info("bsub_call: %s" % bsub_call)
logging.info("command: %s" % command)
out, err, retval = self.system_call(bsub_call, command)
if retval != 0:
try:
out, err, retval = self.system_call(bsub_call, command)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(bsub_call))
time.sleep(gs.WAIT_PERIOD_SSH_TIMEOUT)
continue
break
Expand Down Expand Up @@ -248,8 +247,10 @@ def queue_state(self):
# get bjobs output
system_command = ["bjobs", "-w"]
while True:
out, err, retval = self.system_call(system_command)
if retval != 0:
try:
out, err, retval = self.system_call(system_command)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(system_command))
time.sleep(gs.WAIT_PERIOD_SSH_TIMEOUT)
continue
break
Expand Down
19 changes: 10 additions & 9 deletions sisyphus/simple_linux_utility_for_resource_management_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ def system_call(self, command, send_to_stdin=None):
logging.debug("shell_cmd: %s" % " ".join(system_command))
if send_to_stdin:
send_to_stdin = send_to_stdin.encode()
try:
p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(system_command))
return [], ["TimeoutExpired".encode()], -1

p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)

def fix_output(o):
"""
Expand Down Expand Up @@ -236,8 +233,10 @@ def submit_helper(self, call, logpath, rqmt, name, task_name, start_id, end_id,
sbatch_call += ["-a", "%i-%i:%i" % (start_id, end_id, step_size)]
sbatch_call += ["--wrap=%s" % " ".join(call)]
while True:
out, err, retval = self.system_call(sbatch_call)
if retval != 0:
try:
out, err, retval = self.system_call(sbatch_call)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(sbatch_call))
time.sleep(gs.WAIT_PERIOD_SSH_TIMEOUT)
continue
break
Expand Down Expand Up @@ -306,8 +305,10 @@ def queue_state(self):
"arrayjobid,arraytaskid,state,name:1000",
]
while True:
out, err, retval = self.system_call(system_command)
if retval != 0:
try:
out, err, retval = self.system_call(system_command)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(system_command))
time.sleep(gs.WAIT_PERIOD_SSH_TIMEOUT)
continue
break
Expand Down
19 changes: 10 additions & 9 deletions sisyphus/son_of_grid_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,8 @@ def system_call(self, command, send_to_stdin=None):
logging.debug("shell_cmd: %s" % " ".join(system_command))
if send_to_stdin:
send_to_stdin = send_to_stdin.encode()
try:
p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(system_command))
return [], ["TimeoutExpired".encode()], -1

p = subprocess.run(system_command, input=send_to_stdin, capture_output=True, timeout=30)

def fix_output(o):
"""
Expand Down Expand Up @@ -252,8 +249,10 @@ def submit_helper(self, call, logpath, rqmt, name, task_name, start_id, end_id,
qsub_call += ["-t", "%i-%i:%i" % (start_id, end_id, step_size)]
command = " ".join(call) + "\n"
while True:
out, err, retval = self.system_call(qsub_call, command)
if retval != 0:
try:
out, err, retval = self.system_call(qsub_call, command)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(qsub_call))
time.sleep(gs.WAIT_PERIOD_SSH_TIMEOUT)
continue
break
Expand Down Expand Up @@ -317,8 +316,10 @@ def queue_state(self):
# get qstat output
system_command = ["qstat", "-xml", "-u", getpass.getuser()]
while True:
out, err, retval = self.system_call(system_command)
if retval != 0:
try:
out, err, retval = self.system_call(system_command)
except subprocess.TimeoutExpired:
logging.warning(self._system_call_timeout_warn_msg(system_command))
time.sleep(gs.WAIT_PERIOD_SSH_TIMEOUT)
continue
break
Expand Down

0 comments on commit b9a8016

Please sign in to comment.