I have deployed python app in heroku. The app is mainly working with selenium. Whenever i open the app it started new selenium session. I want to make happen in the same selenium session how is it possible? here is my 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")
Procfile
web gunicorn app:app
It depends how you terminate your session
# close the browser window which is currently in focus.
webdriver.close()
# close the browser and terminates the session
webdriver.quit()
In the first case ( close()
method) each execution opens a new tab while the Webdriver session is still active
OK here is the problem I think you haven't defined the workers. So By default Gunicorn
start three workers which means three selenium session in your case so limit the workers to one and set the time out
web gunicorn app:app --workers=1 --timeout=50
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.