Can instance attributes be reset properly by a function invoked via ThreadPoolExecutor?

Viewed 24

I am using the ThreadPoolExecutor.map() function to call a method in a class (located in a different file, I don't think this is important). The method call is on the same instance of the class.

My question is: If the method uses class variables, which are reset to default values after the method completes, will there still be any values which are mapped incorrectly by the ThreadPoolExecutor map function?

Template code below:

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)

Will there be any discrepancy between iterator and c2.method(value) for value in values (not code, but is conceptually understood) if c2.method uses class variables which are reset?

0 Answers
Related