aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
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)