|
15 | 15 |
|
16 | 16 | from gevent import socket
|
17 | 17 | from greenlet import GreenletExit
|
| 18 | +from threading import Timer |
18 | 19 |
|
19 | 20 | try:
|
20 | 21 | from cStringIO import StringIO
|
|
23 | 24 |
|
24 | 25 | from lib.admin_connection import AdminConnection, AdminAsyncConnection
|
25 | 26 | from lib.box_connection import BoxConnection
|
26 |
| -from lib.colorer import color_stdout, color_log |
| 27 | +from lib.colorer import color_stdout |
| 28 | +from lib.colorer import color_log |
| 29 | +from lib.colorer import qa_notice |
27 | 30 | from lib.preprocessor import TestState
|
28 | 31 | from lib.server import Server
|
29 | 32 | from lib.test import Test
|
@@ -984,9 +987,24 @@ def stop(self, silent=True, signal=signal.SIGTERM):
|
984 | 987 | self.process.send_signal(signal)
|
985 | 988 | except OSError:
|
986 | 989 | pass
|
| 990 | + |
| 991 | + # Waiting for stopping the server. If the timeout |
| 992 | + # reached, send SIGKILL. |
| 993 | + timeout = 5 |
| 994 | + def kill(): |
| 995 | + qa_notice('The server \'{}\' does not stop during {} ' |
| 996 | + 'seconds after the {} ({}) signal.\n' |
| 997 | + 'Info: {}\n' |
| 998 | + 'Sending SIGKILL...'.format( |
| 999 | + self.name, timeout, signal, signame(signal), |
| 1000 | + format_process(self.process.pid))) |
| 1001 | + self.process.kill() |
| 1002 | + timer = Timer(timeout, kill) |
| 1003 | + timer.start() |
987 | 1004 | if self.crash_detector is not None:
|
988 | 1005 | save_join(self.crash_detector)
|
989 | 1006 | self.wait_stop()
|
| 1007 | + timer.cancel() |
990 | 1008 |
|
991 | 1009 | self.status = None
|
992 | 1010 | if re.search(r'^/', str(self._admin.port)):
|
|
0 commit comments