python-2.7 - 使用 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 对象吗?
解决方案
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)
推荐阅读
- python - Selenium 不打开指定的 URL 并显示数据:,
- python - 如何在Python中将一行文本文件向上移动一行?
- firebase - 向 Bucket 创建文件时出现 MediaLink 问题
- android - org.chromium.media.AudioManagerAndroid.hasUsbAudioCommInterface(AudioManagerAndroid.java:1224)的 NullPointerException
- java - 读/写到串行端口 RS232
- powershell - 在 Windows 中批量重命名和复制多个文件
- excel - 带有文件名的 Excel 宏在 Office 2016 64 位中不起作用
- ruby-on-rails - Heroku 上的 Rails 应用程序中出现无法解释的 H18 错误
- multithreading - 对象和线程交互建模
- javascript - React & Redux 应用程序在带有断点的调试模式下表现正确,而在没有断点时表现不正确