From 8bdd722df31a6200b0a656a94687ef2f49628527 Mon Sep 17 00:00:00 2001 From: Scott-Simmons <52365471+Scott-Simmons@users.noreply.github.com> Date: Sat, 26 Jul 2025 16:16:28 +1000 Subject: [PATCH] Changes to windows compatability See: https://github.com/docker/docker-py/blob/6e6a273573fe77f00776b30de0685162a102e43f/docker/transport/npipesocket.py#L180 Attempt to get compat working on windows Unfortunately will hang with recv. Might be better to add a caveat in the README. --- environment.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/environment.py b/environment.py index d4fdf45..e32e998 100644 --- a/environment.py +++ b/environment.py @@ -13,6 +13,8 @@ import base64 import toml +import sys + import exceptions from config_schema import EnvironmentConfig @@ -145,7 +147,15 @@ def reset(self): ) ) - self.socket._sock.setblocking(0) + print("INFO ABOUT SOCKET") + print(self.socket) + print(dir(self.socket)) + print(type(self.socket)) + + if sys.platform == "win32": + self.socket.setblocking(0) + else: + self.socket._sock.setblocking(0) self.socket._writing = True self.emulated_terminal = pyte.HistoryScreen(80, 24) @@ -174,7 +184,10 @@ def act(self, terminal_input_bytes: bytes) -> StepOutcome: visible_lines=[], ) - self.socket.write(terminal_input_bytes) + if sys.platform == "win32": + self.socket.send(terminal_input_bytes) + else: + self.socket.write(terminal_input_bytes) time.sleep(0.2) @@ -189,8 +202,13 @@ def act(self, terminal_input_bytes: bytes) -> StepOutcome: time.sleep(10) container_response = b"" - while b := self.socket.read(1024): + read_func = self.socket.read if sys.platform != "win32" else self.socket.recv + while b := read_func(1024): + print("This is b") + print(b) container_response += b + print("This is the container response:") + print(container_response) if not container_response: return StepOutcome(