|
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.server import DEFAULT_SNAPSHOT_NAME
|
@@ -1018,9 +1021,26 @@ def stop(self, silent=True, signal=signal.SIGTERM):
|
1018 | 1021 | self.process.send_signal(signal)
|
1019 | 1022 | except OSError:
|
1020 | 1023 | pass
|
| 1024 | + |
| 1025 | + # Waiting for stopping the server. If the timeout |
| 1026 | + # reached, send SIGKILL. |
| 1027 | + timeout = 5 |
| 1028 | + |
| 1029 | + def kill(): |
| 1030 | + qa_notice('The server \'{}\' does not stop during {} ' |
| 1031 | + 'seconds after the {} ({}) signal.\n' |
| 1032 | + 'Info: {}\n' |
| 1033 | + 'Sending SIGKILL...'.format( |
| 1034 | + self.name, timeout, signal, signame(signal), |
| 1035 | + format_process(self.process.pid))) |
| 1036 | + self.process.kill() |
| 1037 | + |
| 1038 | + timer = Timer(timeout, kill) |
| 1039 | + timer.start() |
1021 | 1040 | if self.crash_detector is not None:
|
1022 | 1041 | save_join(self.crash_detector)
|
1023 | 1042 | self.wait_stop()
|
| 1043 | + timer.cancel() |
1024 | 1044 |
|
1025 | 1045 | self.status = None
|
1026 | 1046 | if re.search(r'^/', str(self._admin.port)):
|
|
0 commit comments