11
I have a script that makes calls to an API. In order to speed the script up I've tried to implement threading.
The script below works when I'm in IDLE, however when I try to run it with a sys argv from the command line I received two types of errors listed below.
Error 1
Fatal Python error: PyImport_GetModuleDict: no module dictionary!
This application has requests the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
Error 2
Exception in thread Thread-1 (most likely raised during iterpreter shutdown):
Exception in thread Thread-2 (most likely raised during iterpreter shutdown):
Exception in thread Thread-3 (most likely raised during iterpreter shutdown):
Exception in thread Thread-5 (most likely raised during iterpreter shutdown):
I can't find anything on these errors. So, any help is appreciated. Below is the portion of the script that deals with threading.
import threading
import diffbot
urls = [[example.com],[example2.com]]
data = []
def getData(url):
x = diffbot.classify(url)
data.append(x)
def doWork(urls):
for element in urls:
for url in element:
t = threading.Thread(target=getData, args=(url,))
t.daemon = True
t.start()
doWork(urls)