Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
致命的Python错误:PyImport\u GetModuleDigit:没有模块字典_Python_Multithreading_Error Handling_Python Module_Python Multithreading - Fatal编程技术网

致命的Python错误:PyImport\u GetModuleDigit:没有模块字典

致命的Python错误:PyImport\u GetModuleDigit:没有模块字典,python,multithreading,error-handling,python-module,python-multithreading,Python,Multithreading,Error Handling,Python Module,Python Multithreading,我有一个脚本可以调用API。为了加快脚本速度,我尝试实现线程 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 el

我有一个脚本可以调用API。为了加快脚本速度,我尝试实现线程

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)
当我处于空闲状态时,下面的脚本可以工作,但是当我尝试从命令行使用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)

问题是,当您作为独立脚本运行此脚本时,doWork中有许多守护进程线程,但当只剩下守护进程线程时,脚本将退出,因此它们都会被解释器退出而终止。当你在空闲状态下以交互方式运行它时,解释器不会退出,所以你不会遇到这个问题。

这就解释了这个错误--不确定它是否适用于你的情况,尽管通过谷歌搜索第一条错误消息,我猜你是在Windows上。我会添加这些信息(可能还会标记问题“windows”)。还要添加:您正在运行的Python版本,您运行脚本的确切方式,其他Python脚本是否正常运行,diffbot的交互使用(即在Python shell中)是否引发错误。。。