def run(self):
        """Executes the HTTP call.

        Note:
            If this and the parent handler raised an error, the queue item status
            will be set to errored instead of finished. This is to prevent e.g. 404
            recursion.

        """

        try:
            self.__options.callbacks.request_in_thread_before_start(self.__queue_item)
        except Exception as e:
            print(e)

        new_requests = []
        failed = False

        try:
            handler = Handler(self.__options, self.__queue_item)
            new_requests = handler.get_new_requests()

            try:
                self.__queue_item.response.raise_for_status()
            except Exception:
                if self.__queue_item.request.parent_raised_error:
                    failed = True
                else:
                    for new_request in new_requests:
                        new_request.parent_raised_error = True

        except Exception as e:
            failed = True

            error_message = "Setting status of '{}' to '{}' because of an HTTP error.".format(
                self.__queue_item.request.url,
                QueueItem.STATUS_ERRORED
            )

            DebugHelper.output(self.__options, error_message)
            DebugHelper.output(self.__options, e)

            try:
                self.__options.callbacks.request_on_error(self.__queue_item, str(e))
            except Exception as e:
                print(e)

        for new_request in new_requests:
            new_request.parent_url = self.__queue_item.request.url

        try:
            self.__options.callbacks.request_in_thread_after_finish(self.__queue_item)
        except Exception as e:
            print(e)

        with self.__callback_lock:
            self.__callback(self.__queue_item, new_requests, failed)
def run ( self ) : try : self . __options . callbacks . request_in_thread_before_start ( self . __queue_item ) except Exception as e : print ( e ) new_requests = [ ] failed = False try : handler = Handler ( self . __options , self . __queue_item ) new_requests = handler . get_new_requests ( ) try : self . __queue_item . response . raise_for_status ( ) except Exception : if self . __queue_item . request . parent_raised_error : failed = True else : for new_request in new_requests : new_request . parent_raised_error = True except Exception as e : failed = True error_message = "Setting status of '{}' to '{}' because of an HTTP error." . format ( self . __queue_item . request . url , QueueItem . STATUS_ERRORED ) DebugHelper . output ( self . __options , error_message ) DebugHelper . output ( self . __options , e ) try : self . __options . callbacks . request_on_error ( self . __queue_item , str ( e ) ) except Exception as e : print ( e ) for new_request in new_requests : new_request . parent_url = self . __queue_item . request . url try : self . __options . callbacks . request_in_thread_after_finish ( self . __queue_item ) except Exception as e : print ( e ) with self . __callback_lock : self . __callback ( self . __queue_item , new_requests , failed )
Executes the HTTP call.

        Note:
            If this and the parent handler raised an error, the queue item status
            will be set to errored instead of finished. This is to prevent e.g. 404
            recursion.