记录 AttributeError: ‘NoneType‘ object has no attribute ‘nextcall‘

log an error

scrapy test scrapy bench

Appear        

AttributeError: 'NoneType' object has no attribute 'nextcall'

The meaning of the error : an object does not have a nextcall attribute

According to error analysis

Traceback (most recent call last):
  File "D:\pythoninstalllive\lib\site-packages\twisted\internet\defer.py", line 857, in _runCallbacks
    current.result = callback(  # type: ignore[misc]
  File "D:\pythoninstalllive\lib\site-packages\scrapy\core\engine.py", line 187, in <lambda>
    d.addBoth(lambda _: self.slot.nextcall.schedule())

Find out where the error occurred

def _next_request_from_scheduler(self) -> Optional[Deferred]:
        assert self.slot is not None  # typing
        assert self.spider is not None  # typing

        request = self.slot.scheduler.next_request()
        if request is None:
            return None

        d = self._download(request, self.spider)
        d.addBoth(self._handle_downloader_output, request)
        d.addErrback(lambda f: logger.info('Error while handling downloader output',
                                           exc_info=failure_to_exc_info(f),
                                           extra={'spider': self.spider}))
        d.addBoth(lambda _: self.slot.remove_request(request))
        d.addErrback(lambda f: logger.info('Error while removing request from slot',
                                           exc_info=failure_to_exc_info(f),
                                           extra={'spider': self.spider}))
        # d.addBoth(lambda _: self.slot.nextcall.schedule())
        d.addErrback(lambda f: logger.info('Error while scheduling new request',
                                           exc_info=failure_to_exc_info(f),
                                           extra={'spider': self.spider}))
        return d

Try to comment out the error line and run the scrap bench again

Result: OK

Analysis: It should be that a dependent library of scrapy has changed, and an object attribute is deleted. Simply, the error line has little effect on the program, just comment it

Guess you like

Origin blog.csdn.net/superwang04/article/details/125556252