Python 类方法中的ThreadPoolExecutor

Python 类方法中的ThreadPoolExecutor,python,concurrency,Python,Concurrency,我正在运行一些代码,通过ssh上传一些.json文件。为了加快它的执行速度,我尝试实现一个简单的多线程应用程序。我的代码如下所示: def init_json_concurrent(self, countries): with ThreadPoolExecutor(max_workers=5) as executor: executor.map(self.init_json, list(countries)) init_json_concurr

我正在运行一些代码,通过ssh上传一些.json文件。为了加快它的执行速度,我尝试实现一个简单的多线程应用程序。我的代码如下所示:

    def init_json_concurrent(self, countries):

        with ThreadPoolExecutor(max_workers=5) as executor:
            executor.map(self.init_json, list(countries))
init_json_concurrent
init_json
方法是一个类的一部分,该类管理解析json所需的数据。当我试图从另一个脚本调用
init_json_concurrent
方法时,问题就开始了,它只是立即退出,没有引发任何异常或执行任何代码。 当我运行以下操作时,代码执行得很好:

upload = json_upload(_name)

def test_fun(country):
    return upload.init_json(country)

with ThreadPoolExecutor(max_workers=6) as exe:
    exe.map(test_fun, list(countries_))
我已经读到这可能是一个酸洗问题,但我还没有设法获得任何关于如何正确实现这一点的信息

谢谢你的回复

你能提取一个答案并将其包含在你的问题中吗?此外,包括实际观察(错误消息、行为、堆栈跟踪等),而不仅仅是您自己(可能有缺陷)的解释。作为一个新用户,请同时阅读。