I'm trying to write a python script that creates 10 threads at a time and runs until I stop it (ie closing the console). I just need it to do basic logging, so when it fails, its just logs a failed result to a log file.
The part of the script that I need to thread is just a simple selenium script that goes to a webpage and submits a text box.
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('http://www.google.com')
search = browser.find_element_by_name('q')
search.send_keys("google search through python")
search.send_keys(Keys.RETURN) # hit return after you enter search text
time.sleep(5) # sleep for 5 seconds so you can see the results
browser.quit()
I'm unclear what is best to use in this case. As far as I can tell, Python allows concurrent tasks, but only if using the multiprocessing library. If using threading, it may be faster, but not as fast as concurrent cpu tasks.
I'm trying to implement it in futures.concurrency and would be grateful for any suggestions on the best choice to use and how to use it.