Skip to content

Commit

Permalink
Fix and make runtest.py compatible with python2 again
Browse files Browse the repository at this point in the history
  • Loading branch information
cy20lin committed Jul 7, 2023
1 parent 80f2141 commit 9e239ee
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions runtest.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/usr/bin/env python

from __future__ import print_function
import os, sys, re
import argparse, time
import signal, atexit
import threading, queue

from subprocess import Popen, STDOUT, PIPE, TimeoutExpired
from select import select
from subprocess import Popen, STDOUT, PIPE

IS_PY_3 = sys.version_info[0] == 3

if os.name == 'posix':
from select import select
else:
if IS_PY_3:
import threading, queue
from subprocess import TimeoutExpired
else:
import threading
import Queue as queue

debug_file = None
log_file = None

Expand Down Expand Up @@ -216,10 +222,11 @@ def cleanup(self):
self.p.send_signal(signal.CTRL_BREAK_EVENT)
else:
self.p.terminate()
try:
self.p.communicate(timeout=1.0)
except TimeoutExpired:
self.p.kill()
if IS_PY_3:
try:
self.p.communicate(timeout=1.0)
except TimeoutExpired:
self.p.kill()
except OSError:
pass
self.p = None
Expand Down

0 comments on commit 9e239ee

Please sign in to comment.