Changeset: 128d54823476 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/128d54823476
Modified Files:
testing/Mtest.py.in
testing/process.py
Branch: Mar2025
Log Message:
Attempt to stop testing when interrupted.
We now got rid of running tests in their own process group so that
signals get delivered, and we try to cancel any future work.
diffs (148 lines):
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1591,8 +1591,7 @@ def GetBitsAndModsAndThreads(env) :
if procdebug:
print('GetBitsAndModsAndThreads: starting process "%s" (inpipe,
outpipe, errpipe)\n' % '" "'.join(cmd))
with process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE,
- stderr=process.PIPE, text=True,
- process_group=0) as proc:
+ stderr=process.PIPE, text=True) as proc:
stderr = proc.stderr
proc.stdout = process._BufferedPipe(proc.stdout)
proc.stderr = process._BufferedPipe(proc.stderr)
@@ -2663,12 +2662,10 @@ class ServerClass:
stdout = process.PIPE
if os.name == 'nt':
proc = process.Popen(cmd, stdin=stdin, stdout=stdout,
- stderr=stderr, text=True, cwd=cwd, env=env,
-
creationflags=process.CREATE_NEW_PROCESS_GROUP)
+ stderr=stderr, text=True, cwd=cwd, env=env)
else:
proc = process.Popen(cmd, stdin=stdin, stdout=stdout,
- stderr=stderr, text=True, cwd=cwd, env=env,
- process_group=0)
+ stderr=stderr, text=True, cwd=cwd, env=env)
# maybe buffer output as it comes to avoid deadlock
if stdout == process.PIPE:
proc.stdout = process._BufferedPipe(proc.stdout)
@@ -2760,8 +2757,7 @@ def RunIt(cmd, onechild, TestIn, TestOut
with process.Popen(cmd, stdin=TestIn, stdout=TestOut,
stderr=TestErr, text=True,
cwd=TSTTRGDIR, env=environ,
- executable=executable,
- process_group=0) as proc:
+ executable=executable) as proc:
proc.killed = False
proc.onechild = onechild
try:
@@ -4126,29 +4122,33 @@ def main(argv) :
if verbosity > 1:
print('\nRunning all tests in directories %s.\n' %
str(testdirs))
with
concurrent.futures.ThreadPoolExecutor(max_workers=opts.parallel) as tp:
- futures = {tp.submit(PerformDir, env, d, [], test_count):
d for d in testdirs}
- for future in concurrent.futures.as_completed(futures):
- d = futures[future]
- elem, diff, interrupted = future.result()
- if elem is not None:
- if diff <= F_OK:
- body_good.append(elem)
- else:
- body_bad.append(elem)
- if not errseen and diff > F_WARN:
- errseen = True
- if interrupted:
- break
- if not testweb:
- if global_timeout and start_time + global_timeout <
time.time():
- print('\nGlobal testing timeout reached\n')
- break
- if produce_html:
- # after a directory has been tested, create
- # the index file so that we can look at test
- # results while the tests are running
- body = body_bad + body_good
- CreateHtmlIndex(env, '', os.path.join(TSTTRGBASE,
TSTPREF), F_SKIP, F_SKIP, *body)
+ try:
+ futures = {tp.submit(PerformDir, env, d, [],
test_count): d for d in testdirs}
+ for future in concurrent.futures.as_completed(futures):
+ d = futures[future]
+ elem, diff, interrupted = future.result()
+ if elem is not None:
+ if diff <= F_OK:
+ body_good.append(elem)
+ else:
+ body_bad.append(elem)
+ if not errseen and diff > F_WARN:
+ errseen = True
+ if interrupted:
+ break
+ if not testweb:
+ if global_timeout and start_time +
global_timeout < time.time():
+ print('\nGlobal testing timeout reached\n')
+ break
+ if produce_html:
+ # after a directory has been tested, create
+ # the index file so that we can look at
test
+ # results while the tests are running
+ body = body_bad + body_good
+ CreateHtmlIndex(env, '',
os.path.join(TSTTRGBASE, TSTPREF), F_SKIP, F_SKIP, *body)
+ except KeyboardInterrupt:
+ tp.shutdown(cancel_futures=True)
+ raise
if verbosity == 0:
print()
except KeyboardInterrupt:
diff --git a/testing/process.py b/testing/process.py
--- a/testing/process.py
+++ b/testing/process.py
@@ -27,14 +27,6 @@ except ImportError:
DEVNULL = os.open(os.devnull, os.O_RDWR)
__all__ = ['PIPE', 'DEVNULL', 'Popen', 'client', 'server', 'TimeoutExpired']
-try:
- # on Windows, also make this available
- from subprocess import CREATE_NEW_PROCESS_GROUP
-except ImportError:
- pass
-else:
- __all__.append('CREATE_NEW_PROCESS_GROUP')
-
verbose = False
def splitcommand(cmd):
@@ -258,13 +250,6 @@ class Popen(subprocess.Popen):
if sys.hexversion < 0x03070000 and 'text' in kwargs:
kwargs = kwargs.copy()
kwargs['universal_newlines'] = kwargs.pop('text')
- if sys.hexversion < 0x03110000 and 'process_group' in kwargs:
- kwargs = kwargs.copy()
- pgid = kwargs.pop('process_group')
- try:
- kwargs['preexec_fn'] = os.setpgrp
- except AttributeError:
- pass
super().__init__(*args, **kwargs)
def __exit__(self, exc_type, value, traceback):
@@ -577,10 +562,6 @@ class server(Popen):
os.unlink(started)
except OSError:
pass
- if os.name == 'nt':
- kw = {'creationflags': CREATE_NEW_PROCESS_GROUP}
- else:
- kw = {}
starttime = time.time()
super().__init__(cmd + args,
stdin=stdin,
@@ -589,8 +570,7 @@ class server(Popen):
shell=False,
text=True,
bufsize=bufsize,
- encoding='utf-8',
- **kw)
+ encoding='utf-8')
self.isserver = True
if stderr == PIPE:
self.stderr = _BufferedPipe(self.stderr)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]