我构建了一个 scrapy 蜘蛛(scrapy 1.4)。该蜘蛛是通过 django-rq 和supervisord 从 django 网站按需触发的。
这是正在监听 django-rq 事件的supervisord 作业(reddit 用作代理)
[program:rq_worker]
command=python3 manage.py rqworker default
directory=/var/www/django-app
autostart=true
autorestart=true
stderr_logfile=/var/log/rq_worker.err.log
stdout_logfile=/var/log/rq_worker.out.log
这个设置运行良好。
但是,有时(我无法按需重现该问题),所有蜘蛛都会抛出相同的 OpenSSL 错误:
2018-02-11 11:02:19 [scrapy.core.scraper] ERROR: Error downloading <GET https://whateverwebsite.com>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 1299, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/usr/local/lib/python3.5/dist-packages/twisted/python/failure.py", line 393, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/usr/local/lib/python3.5/dist-packages/scrapy/core/downloader/middleware.py", line 43, in process_request
defer.returnValue((yield download_func(request=request,spider=spider)))
twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('', 'osrandom_rand_bytes', 'getrandom() initialization failed.')]>]
重新启动supervisord会使问题消失。
为了确保我的网站及其蜘蛛正常运行,我必须在每次重新启动supervisord时进行测试以确保没有问题。没什么大不了的,但还是...
我想了解那里出了什么问题?
我该如何解决这个问题?与主管有关吗?扭曲相关? openSSL 相关吗?
感谢您的帮助