aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2023-11-09 17:49:12 +0200
committerAndrew Lewis <nerf@judo.za.org>2023-11-09 17:49:12 +0200
commitb891de934a9fa6fed21161bf9545f9357d229b27 (patch)
treed4a4e1dae6266a44beb134a3dc8b555ad99c8235 /test/functional
parent1e62c2b68bf06496e32fd947e3a9297facfa5708 (diff)
downloadrspamd-b891de934a9fa6fed21161bf9545f9357d229b27.tar.gz
rspamd-b891de934a9fa6fed21161bf9545f9357d229b27.zip
[Minor] Try improve test stability
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/util/dummy_http.py6
-rw-r--r--test/functional/util/dummy_killer.py4
2 files changed, 6 insertions, 4 deletions
diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py
index a88b64801..832dbdc79 100755
--- a/test/functional/util/dummy_http.py
+++ b/test/functional/util/dummy_http.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import asyncio
+import dummy_killer
import tornado.ioloop
import tornado.web
import tornado.httpserver
@@ -131,8 +132,7 @@ async def main():
# Write the PID to the specified PID file, if provided
if args.pidfile:
- with open(args.pidfile, "w") as f:
- f.write(str(os.getpid()))
+ dummy_killer.write_pid(args.pidfile)
# Start the server
server.bind(args.port, args.bind)
@@ -141,4 +141,4 @@ async def main():
await asyncio.Event().wait()
if __name__ == "__main__":
- asyncio.run(main()) \ No newline at end of file
+ asyncio.run(main())
diff --git a/test/functional/util/dummy_killer.py b/test/functional/util/dummy_killer.py
index 6b3181608..0a052fb3e 100644
--- a/test/functional/util/dummy_killer.py
+++ b/test/functional/util/dummy_killer.py
@@ -1,6 +1,7 @@
import signal
import os
import atexit
+import tempfile
def setup_killer(server, method = None):
def default_method():
@@ -18,9 +19,10 @@ def setup_killer(server, method = None):
def write_pid(path):
- with open(path, 'w+') as f:
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
f.write(str(os.getpid()))
f.close()
+ os.rename(f.name, path)
def cleanup():
os.remove(path)