Diff
Modified: trunk/Tools/ChangeLog (272168 => 272169)
--- trunk/Tools/ChangeLog 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/ChangeLog 2021-02-01 20:56:39 UTC (rev 272169)
@@ -1,3 +1,29 @@
+2021-02-01 Jonathan Bedard <[email protected]>
+
+ [webkitcorepy] Support machines without Unix signal handling
+ https://bugs.webkit.org/show_bug.cgi?id=221150
+ <rdar://problem/73769605>
+
+ Rubber-stamped by Aakash Jain.
+
+ * Scripts/libraries/webkitcorepy/setup.py: Bump version.
+ * Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Ditto.
+ * Scripts/libraries/webkitcorepy/webkitcorepy/mocks/popen.py:
+ (PopenBase):
+ (PopenBase.send_signal): Handle undefined signal variables.
+ (PopenBase.terminate):
+ (PopenBase.kill):
+ * Scripts/libraries/webkitcorepy/webkitcorepy/task_pool.py:
+ (Process.handler): Handle undefined signal variable.
+ (Process.main): Ditto.
+ * Scripts/libraries/webkitcorepy/webkitcorepy/timeout.py:
+ (Timeout): Timeout class should own SIGALRM.
+ (Timeout.DisableAlarm.__enter__): Do not disable alarm if alarm is not available.
+ (Timeout.check): Pass SIGALRM owned by Timeout object.
+ (Timeout.bind): Do not disable alarm if alarm is not available, use SIGALRM owned by the Timeout object.
+ (Timeout.bind.handler): Ditto.
+ (Timeout.sleep): Use SIGALRM owned by the Timeout object.
+
2021-02-01 Alicia Boya GarcĂa <[email protected]>
autoinstall.py: Don't use an XML parser to parse HTML
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/setup.py (272168 => 272169)
--- trunk/Tools/Scripts/libraries/webkitcorepy/setup.py 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/setup.py 2021-02-01 20:56:39 UTC (rev 272169)
@@ -30,7 +30,7 @@
setup(
name='webkitcorepy',
- version='0.5.1',
+ version='0.5.2',
description='Library containing various Python support classes and functions.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (272168 => 272169)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py 2021-02-01 20:56:39 UTC (rev 272169)
@@ -36,7 +36,7 @@
from webkitcorepy.output_capture import LoggerCapture, OutputCapture, OutputDuplicate
from webkitcorepy.task_pool import TaskPool
-version = Version(0, 5, 1)
+version = Version(0, 5, 2)
from webkitcorepy.autoinstall import Package, AutoInstall
if sys.version_info > (3, 0):
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/popen.py (272168 => 272169)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/popen.py 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/popen.py 2021-02-01 20:56:39 UTC (rev 272169)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -40,6 +40,8 @@
class PopenBase(object):
NEXT_PID = os.getpid() + 1
+ SIGTERM = getattr(signal, 'SIGTERM', 1)
+ SIGKILL = getattr(signal, 'SIGKILL', 2)
def __init__(self, args, bufsize=None, cwd=None, stdin=None, stdout=None, stderr=None):
self._completion = None
@@ -102,16 +104,16 @@
if self.returncode is not None:
return
- if sig not in [signal.SIGTERM, signal.SIGKILL]:
+ if sig not in [self.SIGTERM, self.SIGKILL]:
raise ValueError('Mock Popen object cannot handle signal {}'.format(sig))
log.critical('Mock process {} send signal {}'.format(self.pid, sig))
self.returncode = -1
def terminate(self):
- self.send_signal(signal.SIGTERM)
+ self.send_signal(self.SIGTERM)
def kill(self):
- self.send_signal(signal.SIGKILL)
+ self.send_signal(self.SIGKILL)
if sys.version_info > (3, 0):
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/task_pool.py (272168 => 272169)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/task_pool.py 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/task_pool.py 2021-02-01 20:56:39 UTC (rev 272169)
@@ -227,7 +227,7 @@
@classmethod
def handler(cls, value, _):
- if value == signal.SIGTERM:
+ if value == getattr(signal, 'SIGTERM'):
cls.working = False
@classmethod
@@ -237,7 +237,8 @@
cls.name = name
cls.working = True
- signal.signal(signal.SIGTERM, cls.handler)
+ if getattr(signal, 'SIGTERM'):
+ signal.signal(signal.SIGTERM, cls.handler)
logger = logging.getLogger()
for handler in logger.handlers:
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/subprocess_utils_unittest.py (272168 => 272169)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/subprocess_utils_unittest.py 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/subprocess_utils_unittest.py 2021-02-01 20:56:39 UTC (rev 272169)
@@ -40,11 +40,13 @@
self.assertEqual(result.stdout, None)
self.assertEqual(result.stderr, None)
- def test_run_timeout(self):
- with OutputCapture(), self.assertRaises(TimeoutExpired):
- run([sys.executable, '-c', 'import time;time.sleep(2)'], timeout=1)
+ # Without signal.alarm, the timeout argument will not work in Python 2
+ if Timeout.SIGALRM or sys.version_info > (3, 0):
+ def test_run_timeout(self):
+ with OutputCapture(), self.assertRaises(TimeoutExpired):
+ run([sys.executable, '-c', 'import time;time.sleep(2)'], timeout=1)
- def test_run_timeout_context(self):
- with OutputCapture(), self.assertRaises(TimeoutExpired):
- with Timeout(1):
- run([sys.executable, '-c', 'import time;time.sleep(2)'])
+ def test_run_timeout_context(self):
+ with OutputCapture(), self.assertRaises(TimeoutExpired):
+ with Timeout(1):
+ run([sys.executable, '-c', 'import time;time.sleep(2)'])
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/timeout.py (272168 => 272169)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/timeout.py 2021-02-01 20:51:53 UTC (rev 272168)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/timeout.py 2021-02-01 20:56:39 UTC (rev 272169)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -35,6 +35,7 @@
class Timeout(object):
+ SIGALRM = getattr(signal, 'SIGALRM', None)
_process_to_timeout_map = collections.defaultdict(list)
class Data(object):
@@ -64,7 +65,8 @@
self._patch = None
def __enter__(self):
- signal.alarm(0)
+ if Timeout.SIGALRM:
+ signal.alarm(0)
if self._patch:
self._patch.__enter__()
@@ -111,17 +113,18 @@
current = cls.current()
current.triggered = True
cls.bind()
- current.handler(signal.SIGALRM, None)
+ current.handler(Timeout.SIGALRM, None)
@classmethod
def bind(cls):
current = cls.current()
if not current:
- signal.alarm(0)
+ if Timeout.SIGALRM:
+ signal.alarm(0)
return
def handler(signum, frame):
- assert signum == signal.SIGALRM
+ assert signum == Timeout.SIGALRM
if current.thread_id != threading.current_thread().ident:
log.critical('Using both alarms and threading in the same process, this is unsupported')
raise ValueError('Timeout originates from a different thread')
@@ -131,8 +134,9 @@
current_time = time.time()
cls.check(current_time=current_time)
- signal.signal(signal.SIGALRM, handler)
- signal.alarm(int(math.ceil(current.alarm_time - current_time)))
+ if Timeout.SIGALRM:
+ signal.signal(Timeout.SIGALRM, handler)
+ signal.alarm(int(math.ceil(current.alarm_time - current_time)))
@classmethod
def sleep(cls, seconds):
@@ -142,7 +146,7 @@
current = cls.current()
current.triggered = True
cls.bind()
- current.handler(signal.SIGALRM, None)
+ current.handler(Timeout.SIGALRM, None)
return ORIGINAL_SLEEP(seconds)
def __init__(self, seconds=1, handler=None, patch=True):