diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index af1193556..7100fa797 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -513,8 +513,12 @@ def _write_session_credentials_to_db(self, cur): """, [(k1, k2, v) for (k1, k2), v in config.items()]) @overrides(SpallocJob.get_state) - def get_state(self): - obj = self._get(self._url).json() + def get_state(self, wait_for_change=False): + timeout = 10 + if wait_for_change: + timeout = None + obj = self._get( + self._url, wait=wait_for_change, timeout=timeout).json() return SpallocState[obj["state"]] @overrides(SpallocJob.get_root_host) @@ -603,7 +607,7 @@ def wait_for_state_change(self, old_state): @overrides(SpallocJob.wait_until_ready) def wait_until_ready(self): - state = SpallocState.UNKNOWN + state = self.get_state() while state != SpallocState.READY: state = self.wait_for_state_change(state) if state == SpallocState.DESTROYED: diff --git a/spinnman/spalloc/spalloc_job.py b/spinnman/spalloc/spalloc_job.py index 3ed3edd16..684978ff9 100644 --- a/spinnman/spalloc/spalloc_job.py +++ b/spinnman/spalloc/spalloc_job.py @@ -35,10 +35,12 @@ class SpallocJob(object, metaclass=AbstractBase): __slots__ = () @abstractmethod - def get_state(self) -> SpallocState: + def get_state(self, wait_for_change=False) -> SpallocState: """ Get the current state of the machine. + :param bool wait_for_change: Whether to wait for a change in state + :rtype: SpallocState """