Make handler stop automatically after 25 minutes in case it stalls
This commit is contained in:
parent
2cb50488f4
commit
b037748b5e
1 changed files with 11 additions and 4 deletions
15
handler.py
15
handler.py
|
@ -4,7 +4,7 @@ from bs4 import BeautifulSoup
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
from selenium.common.exceptions import NoSuchElementException
|
from selenium.common.exceptions import NoSuchElementException
|
||||||
import urllib.request, urllib.error, urllib.parse, time, os
|
import multiprocessing, urllib.request, urllib.error, urllib.parse, time, os
|
||||||
import dbtools, phototools, setuptools
|
import dbtools, phototools, setuptools
|
||||||
|
|
||||||
currentRun = []
|
currentRun = []
|
||||||
|
@ -109,11 +109,18 @@ def siteHandler(driver, mode = 0, p = 0, db = dbtools.dbHelper()):
|
||||||
if pageHandler(driver, db):
|
if pageHandler(driver, db):
|
||||||
siteHandler(driver, mode, p+1, db)
|
siteHandler(driver, mode, p+1, db)
|
||||||
|
|
||||||
|
def mainHandler():
|
||||||
|
siteHandler(driver, db=db)
|
||||||
|
siteHandler(driver, 1, db=db)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
db = dbtools.dbHelper()
|
db = dbtools.dbHelper()
|
||||||
driver = webdriver.Firefox()
|
driver = webdriver.Firefox()
|
||||||
if loginHandler(driver):
|
if loginHandler(driver):
|
||||||
siteHandler(driver, db=db)
|
p = multiprocessing.Process(target=mainHandler)
|
||||||
siteHandler(driver, 1, db=db)
|
p.start()
|
||||||
|
p.join(1500)
|
||||||
|
if p.is_alive():
|
||||||
|
p.terminate()
|
||||||
|
p.join()
|
||||||
driver.close()
|
driver.close()
|
||||||
|
|
Loading…
Reference in a new issue