我用celery初始化了一个webdriver对象,但在windows上报告了这个错误。
set_nonblocking() on a file object with no setblocking() method (Windows pipes don't support non-blocking I/O)代码试用:
celery_app = Celery()
celery_app.config_from_object('config.celeryconfig')
from celery import Task
from selenium import webdriver
eventlet.monkey_patch(os=False)
class GetDriver(Task):
test = 'test'
chromedriver_path = "chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver_path)
@celery_app.task(base=GetDriver, bind=True)
def demo(self, params):
print(params)
print(self.test)cellery可以在初始化时初始化webdriver对象吗?
发布于 2019-10-29 15:55:29
celery_app = Celery()
celery_app.config_from_object('config.celeryconfig')
from celery import Task
from selenium import webdriver
eventlet.monkey_patch(os=False)
class GetDriver(Task):
test = 'test'
chromedriver_path = "chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver_path)
@celery_app.task(base=GetDriver, bind=True)
def demo(self, params):
print(params)
print(self.test)发布于 2019-11-26 20:26:18
此错误消息...
set_nonblocking() on a file object with no setblocking() method (Windows pipes don't support non-blocking I/O)...is观察到,在尝试启动/生成新的浏览上下文时,python-2.7解释器无法找到ChromeDriver二进制文件,即Chrome Browser会话。
在您的代码块中,您使用了:
chromedriver_path = "chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver_path)您的程序无法定位chromedriver.exe.因此出现了错误。
解决方案
您需要指出ChromeDriver的绝对路径,如下所示:
chromedriver_path = r'C:\path\to\chromedriver.exe'
driver = webdriver.Chrome(executable_path=chromedriver_path)参考文献
您可以在以下位置找到几个相关的讨论:
超外
发布于 2019-11-27 11:14:29
您是否在启动芹菜服务时添加了参数-P eventlet?我遇到了同样的问题,然后我删除了参数,问题就解决了。
celery -A proj worker -l info -P eventlet (old)
celery -A proj worker -l infohttps://stackoverflow.com/questions/58603198
复制相似问题