我有一个调用 API 的脚本。为了加快脚本速度,我尝试实现线程。
下面的脚本在我处于空闲状态时有效,但是当我尝试从命令行使用 sys argv 运行它时,我收到了下面列出的两种类型的错误。
错误 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.
错误 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):
我找不到关于这些错误的任何信息。因此,任何帮助表示赞赏。下面是处理线程的脚本部分。
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)