Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 def run(self):
     log_status('Starting Task', 'INITIALIZING', self.name, self.task_id)
     self.schedule(self.example_request)
Ejemplo n.º 5
0
 def stop(self):
     self._stop = True
     log_status('Task Stopped', 'FAILED', self.name, self.task_id)