Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import base64
import toml

import sys

import exceptions
from config_schema import EnvironmentConfig

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Comment on lines +206 to +211
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for the first recv call but then hangs.

Probably b/c named pipes are different to sockets

Reference: https://github.com/docker/docker-py/blob/6e6a273573fe77f00776b30de0685162a102e43f/docker/transport/npipesocket.py#L29

image


if not container_response:
return StepOutcome(
Expand Down