##// END OF EJS Templates
Popen.wait(timeout) is new in Python 3.3
MinRK -
Show More
@@ -27,6 +27,23 b' from IPython.utils.py3compat import bytes_to_str'
27 from IPython.utils.sysinfo import get_sys_info
27 from IPython.utils.sysinfo import get_sys_info
28 from IPython.utils.tempdir import TemporaryDirectory
28 from IPython.utils.tempdir import TemporaryDirectory
29
29
30 try:
31 # Python >= 3.3
32 from subprocess import TimeoutExpired
33 def popen_wait(p, timeout):
34 return p.wait(timeout)
35 except ImportError:
36 class TimeoutExpired(Exception):
37 pass
38 def popen_wait(p, timeout):
39 """backport of Popen.wait from Python 3"""
40 for i in range(int(10 * timeout)):
41 if p.poll() is not None:
42 return
43 time.sleep(0.1)
44 if p.poll() is None:
45 raise TimeoutExpired
46
30 NOTEBOOK_SHUTDOWN_TIMEOUT = 10
47 NOTEBOOK_SHUTDOWN_TIMEOUT = 10
31
48
32 class TestController(object):
49 class TestController(object):
@@ -283,8 +300,8 b' class JSController(TestController):'
283 pass
300 pass
284 # wait 10s for the server to shutdown
301 # wait 10s for the server to shutdown
285 try:
302 try:
286 self.server.wait(NOTEBOOK_SHUTDOWN_TIMEOUT)
303 popen_wait(self.server, NOTEBOOK_SHUTDOWN_TIMEOUT)
287 except subprocess.TimeoutExpired:
304 except TimeoutExpired:
288 # server didn't terminate, kill it
305 # server didn't terminate, kill it
289 try:
306 try:
290 print("Failed to terminate notebook server, killing it.",
307 print("Failed to terminate notebook server, killing it.",
@@ -296,8 +313,8 b' class JSController(TestController):'
296 pass
313 pass
297 # wait another 10s
314 # wait another 10s
298 try:
315 try:
299 self.server.wait(NOTEBOOK_SHUTDOWN_TIMEOUT)
316 popen_wait(self.server, NOTEBOOK_SHUTDOWN_TIMEOUT)
300 except subprocess.TimeoutExpired:
317 except TimeoutExpired:
301 print("Notebook server still running (%s)" % self.server_info_file,
318 print("Notebook server still running (%s)" % self.server_info_file,
302 file=sys.stderr
319 file=sys.stderr
303 )
320 )
General Comments 0
You need to be logged in to leave comments. Login now