Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.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 通过ThreadPoolExecutor调用的函数能否正确重置实例属性?_Python_Multithreading_Threadpoolexecutor - Fatal编程技术网

Python 通过ThreadPoolExecutor调用的函数能否正确重置实例属性?

Python 通过ThreadPoolExecutor调用的函数能否正确重置实例属性?,python,multithreading,threadpoolexecutor,Python,Multithreading,Threadpoolexecutor,我正在使用ThreadPoolExecutor.map()函数调用类中的方法(位于不同的文件中,我认为这并不重要)。方法调用在类的同一实例上 我的问题是:如果该方法使用类变量(在该方法完成后重置为默认值),是否仍有任何值被ThreadPoolExecutormap函数错误映射 模板代码如下: import class2 from classFile2 from concurrent.futures import ThreadPoolExecutor c2 = class2() def eval

我正在使用
ThreadPoolExecutor.map()
函数调用类中的方法(位于不同的文件中,我认为这并不重要)。方法调用在类的同一实例上

我的问题是:如果该方法使用类变量(在该方法完成后重置为默认值),是否仍有任何值被
ThreadPoolExecutor
map函数错误映射

模板代码如下:

import class2 from classFile2
from concurrent.futures import ThreadPoolExecutor

c2 = class2()
def eval(values):
    with ThreadPoolExecutor() as exe:
        iterator = exe.map(c2.method, values, timeout=0.5, chunksize=1)

如果
c2.method
使用重置的类变量,那么
iterator
c2.method(value)之间是否会有任何差异。如果
r1=c2.method(v1)
r2=c2.method(v2)
result=[r1,r2]
,那么这是否等于
pool.map(c2,method,values,…)
,在这种情况下,不等于。问题的出现是因为类的单个实例被多个线程并发使用。