def example_request(self, response: Optional[HttpResponse] = None): if response is None: return self.request \ .set_url("https://www.offspring.co.uk/") \ .set_method("GET") \ .build() log_status('Task Completed Request', 'FINISHED', self.name, self.task_id) return self.schedule(self.example_request)
def handle_unknown_responses(self, response: WebSocketResponse): """ Called when no response handler was registered for a scheduled task Normally this shouldn't happen, so by default a warning will be printed to console. Override this method to customize its behaviour :param response: :return: """ log_status(f'Task Crashed Unknown Error', 'FAILED', self.name, self.task_id)
def handle_errors(self, err: str, response_callback: callable): """ Called when a goclient returns a (fatal) error in a response By default stop() will be called and an unrecoverable error will be thrown! Override this method to customize its behaviour :param err: :return: """ # self.stop() #raise Exception("Task failed with error: " + err) self.schedule_sleep_thread(response_callback) log_status( 'Example Error In Single Thread - Other Threads Should Continue Running But Are Being Blocked By This Sleep', 'FAILED', self.name, self.task_id)
def run(self): log_status('Starting Task', 'INITIALIZING', self.name, self.task_id) self.schedule(self.example_request)
def stop(self): self._stop = True log_status('Task Stopped', 'FAILED', self.name, self.task_id)