From 298f6e1020c897ccaed818091d25134fc26fa0e1 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 17 Dec 2023 17:44:09 +0100 Subject: [PATCH] _x11.py: Make Xpra connectability check more robust --- sandwine/_x11.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sandwine/_x11.py b/sandwine/_x11.py index ac0128e..d513f3c 100644 --- a/sandwine/_x11.py +++ b/sandwine/_x11.py @@ -199,6 +199,15 @@ def _write_xvfh_wrapper_script_to(xvfb_wrapper_path): file=f) os.fchmod(f.fileno(), 0o755) # i.e. make executable + def _wait_for_connectable_xpra_server(self, unix_socket_path: str) -> None: + while True: + ret = subprocess.call([self._command, 'id', unix_socket_path], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + if ret == 0: + return + time.sleep(0.5) + def __enter__(self): _logger.info(self._message_starting) @@ -260,6 +269,7 @@ def __enter__(self): try: self._server_process = subprocess.Popen(server_argv) _wait_until_file_present(unix_socket_path) + self._wait_for_connectable_xpra_server(unix_socket_path) self._client_process = subprocess.Popen(client_argv, env=client_env) except FileNotFoundError: _logger.error(f'Command {self._command!r} is not available, aborting.')