Skip to content

Commit

Permalink
FIX: Wait for visualization server to be ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcCote committed Feb 8, 2022
1 parent d8e4bd4 commit 634a0f8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions textworld/render/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def wait_task():
thread = Thread(target=wait_task, name='waiting_on_parent_exit')
thread.start()

self.parent_conn.recv() # Wait until server is ready.
print("Viewer started at http://localhost:{}.".format(self.port))
if self.open_automatically:
check_modules(["webbrowser"], missing_modules)
Expand Down Expand Up @@ -262,6 +263,7 @@ def listen(conn: Connection, results: Queue):
:param conn: child connection from multiprocessing.Pipe.
:param results: thread-safe queue for results.
"""
conn.send("Ready!") # Tell the main thread the server is ready.
while True:
game_state = conn.recv()
results.put(game_state)
Expand Down

0 comments on commit 634a0f8

Please sign in to comment.