Skip to content

Commit

Permalink
Merge pull request #232 from threedworld-mit/missing_json
Browse files Browse the repository at this point in the history
Missing json
  • Loading branch information
alters-mit authored Jul 26, 2021
2 parents 7784cdc + 9dacb91 commit eeddb5d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Documentation/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

To upgrade from TDW v1.7 to v1.8, read [this guide](Documentation/upgrade_guides/v1.7_to_v1.8).

## v1.8.21

### Build

- Fixed: Rare bug where the build won't receive the full JSON string for very long lists of commands. In these cases, the build will request that the controller resend the message.
- Fixed: Rare bug in which the controller enters an infinite loop trying to resend messages to the build. Now, it will quit with an error after a certain number of retries.

## v1.8.20

### Command API
Expand Down
2 changes: 1 addition & 1 deletion Python/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
from pathlib import Path

__version__ = "1.8.20.0"
__version__ = "1.8.21.0"
readme_path = Path('../README.md')
if readme_path.exists():
long_description = readme_path.read_text(encoding='utf-8')
Expand Down
26 changes: 20 additions & 6 deletions Python/tdw/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tdw.librarian import ModelLibrarian, SceneLibrarian, MaterialLibrarian, HDRISkyboxLibrarian, \
HumanoidAnimationLibrarian, HumanoidLibrarian, HumanoidAnimationRecord, RobotLibrarian
from tdw.backend.paths import EDITOR_LOG_PATH, PLAYER_LOG_PATH
from tdw.output_data import OutputData, Version, QuitSignal
from tdw.output_data import Version, QuitSignal
from tdw.release.build import Build
from tdw.release.pypi import PyPi
from tdw.version import __version__
Expand Down Expand Up @@ -143,14 +143,28 @@ def communicate(self, commands: Union[dict, List[dict]]) -> list:
# If the controller receives the dummy object, it should re-send its commands.
# The dummy object is always in an array: [ftre, 0]
# This way, the controller can easily differentiate it from a response that just has the frame count.
while len(resp) > 1 and OutputData.get_data_type_id(resp[0]) == "ftre":
self.socket.send_multipart(msg)
resp = self.socket.recv_multipart()
ftre: bool = True
num_ftre: int = 0
while ftre and num_ftre < 1000:
ftre = False
for i in range(len(resp) - 1):
if resp[i][4:8] == b'ftre':
ftre = True
self.socket.send_multipart(msg)
resp = self.socket.recv_multipart()
num_ftre += 1
break
# Tried too many times.
if ftre:
print("Quitting now because the controller tried too many times to resend commands to the build. "
"Check the build log for more info.")
self._print_build_log()
self._local_build_is_running = False
self._quit = True

# Check if we've received a quit signal. If we have, check if there was an error.
for i in range(len(resp) - 1):
r_id = OutputData.get_data_type_id(resp[i])
if r_id == "quit":
if resp[i][4:8] == b'quit':
if not QuitSignal(resp[i]).get_ok():
print("The build quit due to an error. Check the build log for more info.")
self._print_build_log()
Expand Down
2 changes: 1 addition & 1 deletion Python/tdw/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.8.20"
__version__ = "1.8.21"

0 comments on commit eeddb5d

Please sign in to comment.