Make handler stop automatically after 25 minutes in case it stalls

This commit is contained in:
Klaus-Uwe Mitterer 2016-08-07 21:59:23 +02:00
parent 2cb50488f4
commit b037748b5e

View file

@ -4,7 +4,7 @@ from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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
currentRun = []
@ -109,11 +109,18 @@ def siteHandler(driver, mode = 0, p = 0, db = dbtools.dbHelper()):
if pageHandler(driver, db):
siteHandler(driver, mode, p+1, db)
def mainHandler():
siteHandler(driver, db=db)
siteHandler(driver, 1, db=db)
if __name__ == "__main__":
db = dbtools.dbHelper()
driver = webdriver.Firefox()
if loginHandler(driver):
siteHandler(driver, db=db)
siteHandler(driver, 1, db=db)
p = multiprocessing.Process(target=mainHandler)
p.start()
p.join(1500)
if p.is_alive():
p.terminate()
p.join()
driver.close()