Skip to content

Commit

Permalink
Explicityl wait for return code
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Feb 16, 2015
1 parent 3a11fa0 commit c76e870
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions chess/uci.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ def send_line(self, string):
self.process.stdin.write("\n")
self.process.stdin.flush()

def get_return_code(self):
def wait_for_return_code(self):
self.process.wait()
return self.process.returncode


Expand Down Expand Up @@ -552,8 +553,8 @@ def send_line(self, string):
self.process.stdin_write(string.encode("utf-8"))
self.process.stdin_write(b"\n")

def get_return_code(self):
return self._result.return_code if self._result else None
def wait_for_return_code(self):
return self.process.wait_for_result().return_code


class Engine(object):
Expand Down Expand Up @@ -622,7 +623,8 @@ def _stdin_thread_target(self):
self.on_terminated()

def on_terminated(self):
self.return_code = self.process.get_return_code()
self.process.close_std_streams()
self.return_code = self.process.wait_for_return_code()
self.terminated.set()

def _id(self, arg):
Expand Down

0 comments on commit c76e870

Please sign in to comment.