def on_timeout(self): # FIXME: go back to earlier state if request failed counter = self.machine.increment_counter(self.state_name) request_config = data.request_config(self.machine.request_id) device_name = request_config['assigned_device'] device_state = data.device_status(device_name)['state'] if device_state == 'ready': self.machine.goto_state(ready) elif counter > self.PERMANENT_FAILURE_COUNT: self.machine.goto_state(device_not_found) else: self.machine.goto_state(pending)
def on_timeout(self): # FIXME: go back to earlier state if request failed counter = self.machine.increment_counter(self.state_name) request_config = data.request_config(self.machine.request_id) device_name = request_config['assigned_device'] print 'device_name is %s' % device_name device_state = data.device_status(device_name)['state'] if device_state == 'ready': self.machine.goto_state(ready) elif counter > self.PERMANENT_FAILURE_COUNT: self.machine.goto_state(device_not_found) else: self.machine.goto_state(pending)
def on_entry(self): request_config = data.request_config(self.machine.request_id) device_name = request_config['assigned_device'] device_state = data.device_status(device_name)['state'] if device_state != 'free': self.logger.error('Assigned device %s is in unexpected state %s ' 'when about to contact lifeguard.' % (device_name, device_state)) self.machine.goto_state(device_busy) return if self.contact_lifeguard(request_config): self.machine.goto_state(pending) return counters = self.machine.read_counters() if counters.get(self.state_name, 0) > self.PERMANENT_FAILURE_COUNT: self.machine.goto_state(device_not_found)
def on_entry(self): request_config = data.request_config(self.machine.request_id) device_name = request_config['assigned_device'] device_state = data.device_status(device_name)['state'] if device_state != 'free': logs.request_logs.add( self.machine.request_id, 'assigned device %s is in unexpected state %s when about ' 'to contact lifeguard.' % (device_name, device_state)) self.machine.goto_state(device_busy) return if self.contact_lifeguard(): self.machine.goto_state(pending) return counters = self.machine.read_counters() if counters.get(self.state_name, 0) > self.PERMANENT_FAILURE_COUNT: self.machine.goto_state(device_not_found)
def GET(self, id): return data.device_status(id)