aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/util/dummy_http.py
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-07 17:59:28 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-07 17:59:28 +0100
commit8f30094140387762c57c559d536c72db779cf4e0 (patch)
tree74832475acf94b8e2b6043659773dfc5c83bf9dc /test/functional/util/dummy_http.py
parent2b9a86ba167d3d3508c7a6ee76d24245332386b4 (diff)
downloadrspamd-8f30094140387762c57c559d536c72db779cf4e0.tar.gz
rspamd-8f30094140387762c57c559d536c72db779cf4e0.zip
[Test] Small refactoring in dummy services test
Moved code for pid writing and terminating into a separated module. Also added cleanup: in some cases, processes remained in the system after test is done. It should not happen anymore
Diffstat (limited to 'test/functional/util/dummy_http.py')
-rwxr-xr-xtest/functional/util/dummy_http.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py
index 4814613ea..dc4cee354 100755
--- a/test/functional/util/dummy_http.py
+++ b/test/functional/util/dummy_http.py
@@ -3,11 +3,11 @@
import BaseHTTPServer
import SocketServer
import SimpleHTTPServer
+import dummy_killer
import time
import os
import sys
-import signal
import socket
PORT = 18080
@@ -90,9 +90,7 @@ class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
self.timeout = 1
def run(self):
- with open(PID, 'w+') as f:
- f.write(str(os.getpid()))
- f.close()
+ dummy_killer.write_pid(PID)
try:
while 1:
sys.stdout.flush()
@@ -101,7 +99,6 @@ class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
print "Interrupt"
except socket.error:
print "Socket closed"
- pass
def stop(self):
self.keep_running = False
@@ -111,11 +108,6 @@ class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
if __name__ == '__main__':
server = ThreadingSimpleServer()
- def alarm_handler(signum, frame):
- server.stop()
-
- signal.signal(signal.SIGALRM, alarm_handler)
- signal.signal(signal.SIGTERM, alarm_handler)
- signal.alarm(1000)
+ dummy_killer.setup_killer(server, server.stop)
server.run()