rishi1985 commited on
Commit
25e77f1
·
1 Parent(s): b353801

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -16
app.py CHANGED
@@ -368,20 +368,22 @@ async def get_answer(q: Query ):
368
 
369
 
370
  def do_ML2(id:str,text:str,host:str, trycount:int):
371
-
372
- try:
373
- # starttime=time.time()
374
 
375
- options = ChromeOptions()
376
- options.add_argument('--no-sandbox')
377
- options.add_argument('-headless')
378
- service = Service()
379
- driver = webdriver.Chrome(options= options,service=service)
380
- driver.get("https://talkai.info/image/")
 
 
381
  while True:
382
- # currtime= time.time()
383
- # if(currtime>starttime+10):
384
- # return "Requested Could not be proceed"
 
385
  try:
386
  textarea = driver.find_element(By.CSS_SELECTOR, "textarea")
387
  textarea.send_keys(text)
@@ -394,9 +396,10 @@ def do_ML2(id:str,text:str,host:str, trycount:int):
394
 
395
  # time.sleep(2)
396
  while True:
397
- # currtime= time.time()
398
- # if(currtime>starttime+10):
399
- # return "Requested Could not be proceed"
 
400
 
401
  time.sleep(0.2)
402
  # currtime= time.time()
@@ -420,7 +423,7 @@ def do_ML2(id:str,text:str,host:str, trycount:int):
420
  except:
421
  print("Error")
422
  driver.delete_all_cookies()
423
- if trycount>1:
424
 
425
  return "Request Could not be proceed"
426
  driver.quit()
 
368
 
369
 
370
  def do_ML2(id:str,text:str,host:str, trycount:int):
371
+
372
+ starttime=time.time()
 
373
 
374
+ options = ChromeOptions()
375
+ options.add_argument('--no-sandbox')
376
+ options.add_argument('-headless')
377
+ service = Service()
378
+ driver = webdriver.Chrome(options= options,service=service)
379
+ driver.get("https://talkai.info/image/")
380
+ try:
381
+
382
  while True:
383
+ currtime= time.time()
384
+ if(currtime>starttime+5):
385
+ raise ValueError("h")
386
+ # return "Requested Could not be proceed"
387
  try:
388
  textarea = driver.find_element(By.CSS_SELECTOR, "textarea")
389
  textarea.send_keys(text)
 
396
 
397
  # time.sleep(2)
398
  while True:
399
+ currtime= time.time()
400
+ if(currtime>starttime+40):
401
+ raise ValueError("j")
402
+ return "Requested Could not be proceed"
403
 
404
  time.sleep(0.2)
405
  # currtime= time.time()
 
423
  except:
424
  print("Error")
425
  driver.delete_all_cookies()
426
+ if trycount>4:
427
 
428
  return "Request Could not be proceed"
429
  driver.quit()