Skip to content

Commit

Permalink
✨ Raise exception after 17 mins
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed May 16, 2024
1 parent 34a8aca commit 7715aaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions craftground/craftground/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@


def wait_for_server(port: int) -> socket.socket:
wait_time = 1
next_output = 1 # 3 7 15 31 63 127 255 seconds passed

while True:
try:
socket_path = f"/tmp/minecraftrl_{port}.sock"
Expand All @@ -20,9 +23,14 @@ def wait_for_server(port: int) -> socket.socket:
s.settimeout(30)
return s
except (ConnectionRefusedError, FileNotFoundError):
print(
f"Waiting for server on port {port}...",
)
if wait_time == next_output:
print(
f"Waiting for server on port {port}...",
)
next_output *= 2
if next_output > 1024:
raise Exception("Server not started within 1024 seconds")
wait_time += 1
time.sleep(1)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
packages = find_packages()
setup(
name="craftground",
version="1.8.0",
version="1.8.1",
packages=packages,
install_requires=["gymnasium", "Pillow", "numpy", "protobuf", "typing_extensions"],
author="yhs0602",
Expand Down

0 comments on commit 7715aaa

Please sign in to comment.