Question:
I have a simple HTTP server with can get information from web and send it to Telegram.
And I faced with a strange problem - if I use Webdriver.Chrome only once and then my HTTP server freezes and couldn’t answer the request.
And I should restart server after every request.
I tried to remove the Webdriver call - then the server can accept new requests after processing the previous ones.
That is, the problem is exclusively in Webdriver.
I have tried different combinations of shutdown - driver.close() and driver.quit(). There is no difference in behavior. There are no errors or exceptions.
I don’t understand how to solve the problem.
Help me please )
Repl link:
from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.chrome.options import Options
import time
import config
from replit import db
from datetime import datetime
from threading import Thread
import telegrambot
from tkinter import Tk
from PIL import Image
import os
from chromedriver_py import binary_path
from webdriver_manager.chrome import ChromeDriverManager
def setup( url ):
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--force-dark-mode')
driver = webdriver.Chrome(options=chrome_options)
driver.get(url)
...
driver.close()
driver.quit()