[英]How to keep browser session alive for 10 min on heroku using selenium?
[英]How to keep the selenium session alive in heroku?
我已经在 heroku 中部署了 python 应用程序。 该应用程序主要使用硒。 每当我打开应用程序时,它都会启动新的硒会话。 我想在同一个 selenium 会话中实现,这怎么可能? 这是我的 chrome_options。
options = Options()
options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
options.add_argument("--disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument('--single-process')
options.add_argument('--disable-gpu')
options.add_argument('--remote-debugging-port=9222')
options.add_argument('--disable-browser-side-navigation')
browser = webdriver.Chrome(options=options, executable_path=os.environ.get("CHROMEDRIVER_PATH"))
options.add_argument("--example-flag")
配置文件
web gunicorn app:app
这取决于您如何终止会话
# close the browser window which is currently in focus.
webdriver.close()
# close the browser and terminates the session
webdriver.quit()
在第一种情况下( close()
方法),每次执行都会在 Webdriver 会话仍处于活动状态时打开一个新选项卡
好的,这是我认为您尚未定义工人的问题。 因此,默认情况下Gunicorn
启动三个工作人员,这意味着在您的情况下进行三个硒会话,因此将工作人员限制为一个并设置超时
web gunicorn app:app --workers=1 --timeout=50
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.