concurrently running instances of chromium are fucking each other up

This commit is contained in:
Bla 2023-10-27 16:43:12 +00:00
parent 5ec387e097
commit 5a3d7aa5c9

View file

@ -91,7 +91,7 @@ def ids():
l = filter(idIsRecent,list(valuestore.keys()))
return ','.join(map(str,list(l)))
def createDriver():
def createDriver(id):
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument("--incognito")
@ -101,7 +101,15 @@ def createDriver():
options.add_argument("--no-sandbox")
options.add_argument("--enable-javascript")
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=options)
data_dir = "--user-data-dir=/tmp/" + str(id)
options.add_argument(data_dir)
try:
driver = webdriver.Chrome(options=options)
except selenium.common.exceptions.SessionNotCreatedException:
sleep(10)
driver = createDriver(id)
return driver
driver.response_interceptor = interceptor
return driver
@ -115,7 +123,7 @@ if __name__ == '__main__':
restartWait = timedelta(hours=4)
# setup webdriver
d0 = createDriver()
d0 = createDriver(0)
# start initial driver
d0.get('https://dus-travis.dus.com/')
@ -125,14 +133,14 @@ if __name__ == '__main__':
while True:
sleep(30)
if datetime.now(timezone.utc) > lastaccess + restartWait:
d1 = createDriver()
d1 = createDriver(1)
d1.get('https://dus-travis.dus.com/')
print ("New Failover Driver started, waiting 10 seconds ...")
sleep(10)
killChildren(d0)
del d0
print ("Original driver deleted")
d0 = createDriver()
d0 = createDriver(0)
d0.get('https://dus-travis.dus.com/')
print ("Recreating original driver and waiting 10 seconds ...")
sleep(10)