首页 > 解决方案 > 使用 ChromeDriver Selenium CeleryPython 在没有 setblocking() 方法的文件对象上设置 set_nonblocking()(Windows 管道不支持非阻塞 I/O)

问题描述

我用 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 对象吗?

标签: python-2.7google-chromeselenium-webdriverselenium-chromedrivercelery

解决方案


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)

推荐阅读