I'm trying to perform multithreading in python and am still trying to get my head around the picklability requirement and how much I can keep my code OOP.
Can you run ThreadPoolExecutor from within a class passing it a function defined at the module level? My setup is as follows:
moduleA.py:
def foo():
run some stuff
class bar(object):
def runThreads(self):
executor = futures.ThreadPoolExecutor(5)
executor.submit(foo) # do this 5 times in some sort of loop
I'd like to be able to call this from a separate module
moduleB.py
from moduleA import bar
A = bar()
A.runThreads()
Will this work? Do I need to import foo as well?