All,
In my GUI I'm using multiprocessing to run a function. But the pool start multiple GUI.
I have read that peoples add if __name__ == '__main__':
in their code and it seems to work.
But I don't know if this trick will work in my case, and where I have to insert this code.
The function run_func() is launched by a button in the GUI.
How can I block this multiple start?
I have a second question: How can I do to unimport setup at the end of the exec?
Thanks a lot !
@pyqtSlot()
def run_func():
run="""
import os
import sys
from setup import *
print('toto')
print('titi')
"""
from multiprocessing import Pool
pool = Pool(processes=4)
asyncResult = pool.apply_async(exec(run),{},{}),range(1)