Skip to content

Commit

Permalink
add sigterm handling to wptrunner (#37591)
Browse files Browse the repository at this point in the history
* rebase

* fix handler name
  • Loading branch information
nihardamar authored and pull[bot] committed Nov 3, 2023
1 parent b68a9ed commit 1147998
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/wptrunner/wptrunner/wptrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import os
import signal
import sys
from collections import defaultdict
from datetime import datetime, timedelta
Expand Down Expand Up @@ -257,6 +258,7 @@ def run_test_iteration(test_status, test_loader, test_source_kwargs, test_source
run_test_kwargs["restart_on_new_group"],
recording=recording) as manager_group:
try:
handle_interrupt_signals()
manager_group.run(tests_to_run)
except KeyboardInterrupt:
logger.critical("Main thread got signal")
Expand All @@ -274,6 +276,14 @@ def run_test_iteration(test_status, test_loader, test_source_kwargs, test_source

return True

def handle_interrupt_signals():
def termination_handler(_signum, _unused_frame):
raise KeyboardInterrupt()
if sys.platform == "win32":
signal.signal(signal.SIGBREAK, termination_handler)
else:
signal.signal(signal.SIGTERM, termination_handler)


def evaluate_runs(test_status, run_test_kwargs):
"""Evaluates the test counts after the given number of repeat runs has finished"""
Expand Down

0 comments on commit 1147998

Please sign in to comment.