mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
Python tests: Daemon ported to Windows
Instead of using os.fork (not supported on Windows), subprocess.Popen is used and os.pipe was replaced with Windows pipes. To be able to identify the child process, an extra parameter was added to daemon process '--pipe-handle'. This parameter contains the parent Windows pipe handle which is used by the child to notify the parent about the startup. The PID file is created directly on Windows, without using a temporary file because the symbolic link does not inherit the file lok set on the temporary file. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
This commit is contained in:
committed by
Gurucharan Shetty
parent
03947eb7ec
commit
9e03d7344c
@@ -59,6 +59,17 @@ def add_file_to_unlink(file):
|
||||
_files[file] = None
|
||||
|
||||
|
||||
def add_file_to_close_and_unlink(file, fd=None):
|
||||
"""Registers 'file' to be unlinked when the program terminates via
|
||||
sys.exit() or a fatal signal and the 'fd' to be closed. On Windows a file
|
||||
cannot be removed while it is open for writing."""
|
||||
global _added_hook
|
||||
if not _added_hook:
|
||||
_added_hook = True
|
||||
add_hook(_unlink_files, _cancel_files, True)
|
||||
_files[file] = fd
|
||||
|
||||
|
||||
def remove_file_to_unlink(file):
|
||||
"""Unregisters 'file' from being unlinked when the program terminates via
|
||||
sys.exit() or a fatal signal."""
|
||||
@@ -78,6 +89,8 @@ def unlink_file_now(file):
|
||||
|
||||
def _unlink_files():
|
||||
for file_ in _files:
|
||||
if sys.platform == "win32" and _files[file_]:
|
||||
_files[file_].close()
|
||||
_unlink(file_)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user