|
@@ -1,6 +1,6 @@
|
|
|
#coding=utf-8
|
|
|
from _execute import *
|
|
|
-import concurrent.futures
|
|
|
+import multiprocessing
|
|
|
|
|
|
clickvideo = 2 # set to 1 to alert if video is found (DOES NOT CLICK!), requires whitelist
|
|
|
# ^ set to 2 to click the video when found, requires whitelist
|
|
@@ -18,33 +18,33 @@ def addvids(target):
|
|
|
return target
|
|
|
|
|
|
def exe():
|
|
|
- start_time = time.time()
|
|
|
target=[]
|
|
|
kw = pickterm(client)
|
|
|
target = addvids(target)
|
|
|
print(len(target))
|
|
|
process_one(kw, target, clickvideo, savefile, sec)
|
|
|
- duration = time.time()-start_time
|
|
|
- print("Runs: " + str(runcount) + " | Duration: " + str(duration))
|
|
|
|
|
|
-if clickvideo == 1 or clickvideo == 2:
|
|
|
- runcount=0
|
|
|
- kws=None
|
|
|
- while True:
|
|
|
- try:
|
|
|
- runcount+=1
|
|
|
- with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
|
|
|
- future = executor.submit(exe)
|
|
|
- try:
|
|
|
- result = future.result(timeout=120)
|
|
|
- print("Function completed")
|
|
|
- except concurrent.futures.TimeoutError:
|
|
|
- print("Function execution timed out")
|
|
|
- future.cancel()
|
|
|
- except:
|
|
|
- print('Runtime Error')
|
|
|
- traceback.print_exc()
|
|
|
- time.sleep(7)
|
|
|
+if __name__ == '__main__':
|
|
|
+ if clickvideo == 1 or clickvideo == 2:
|
|
|
+ runcount=0
|
|
|
+ kws=None
|
|
|
+ while True:
|
|
|
+ try:
|
|
|
+ runcount+=1
|
|
|
+ start_time = time.time()
|
|
|
+ p = multiprocessing.Process(target=exe)
|
|
|
+ p.start()
|
|
|
+ p.join(120)
|
|
|
+ if p.is_alive():
|
|
|
+ print("Overtime")
|
|
|
+ p.kill()
|
|
|
+ p.join()
|
|
|
+ duration = time.time()-start_time
|
|
|
+ print("Runs: " + str(runcount) + " | Duration: " + str(duration))
|
|
|
+ except:
|
|
|
+ print('Runtime Error')
|
|
|
+ traceback.print_exc()
|
|
|
+ time.sleep(7)
|
|
|
|
|
|
-elif savefile == 1:
|
|
|
- execute(termlist, "", clickvideo, savefile, sec)
|
|
|
+ elif savefile == 1:
|
|
|
+ execute(termlist, "", clickvideo, savefile, sec)
|