Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2567)

Unified Diff: appengine/swarming/swarming_bot/bot_code/task_runner.py

Issue 1373133004: Fixes and add smoke test: hard timeout on isolated task. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: . Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/swarming_bot/__main__.py ('k') | appengine/swarming/tools/start_bot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/swarming_bot/bot_code/task_runner.py
diff --git a/appengine/swarming/swarming_bot/bot_code/task_runner.py b/appengine/swarming/swarming_bot/bot_code/task_runner.py
index 7587e88a9bf7ef6c1046ee2d9e16866d551734ed..b9ecb27835fa8e00e0f404521d71c21ad6de8ede 100644
--- a/appengine/swarming/swarming_bot/bot_code/task_runner.py
+++ b/appengine/swarming/swarming_bot/bot_code/task_runner.py
@@ -345,6 +345,7 @@ def run_command(
had_hard_timeout = False
had_io_timeout = False
must_signal_internal_failure = None
+ kill_sent = False
timed_out = None
try:
calc = lambda: calc_yield_wait(
@@ -372,34 +373,26 @@ def run_command(
if not timed_out:
if now - last_io > task_details.io_timeout:
had_io_timeout = True
- logging.warning('I/O timeout')
- try:
- proc.terminate()
- except OSError:
- pass
+ logging.warning('I/O timeout; sending SIGTERM')
+ proc.terminate()
timed_out = monotonic_time()
elif now - start > task_details.hard_timeout:
had_hard_timeout = True
- logging.warning('Hard timeout')
- try:
- proc.terminate()
- except OSError:
- pass
+ logging.warning('Hard timeout; sending SIGTERM')
+ proc.terminate()
timed_out = monotonic_time()
else:
# During grace period.
- if now >= timed_out + task_details.grace_period:
+ if not kill_sent and now >= timed_out + task_details.grace_period:
# Now kill for real. The user can distinguish between the following
# states:
# - signal but process exited within grace period,
# (hard_|io_)_timed_out will be set but the process exit code will
# be script provided.
# - processed exited late, exit code will be -9 on posix.
- try:
- logging.warning('proc.kill() after grace')
- proc.kill()
- except OSError:
- pass
+ logging.warning('Grace exhausted; sending SIGKILL')
+ proc.kill()
+ kill_sent = True
logging.info('Waiting for proces exit')
exit_code = proc.wait()
except MustExit as e:
« no previous file with comments | « appengine/swarming/swarming_bot/__main__.py ('k') | appengine/swarming/tools/start_bot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698