I am working on a window form application and I need to call some code from python. In python multiprocessing module is used which causes a fork in window form or spawns multiple windows. I am posting here a demo code for more understanding. Please if anyone knows about it suggest to me something to solve it. Thanks
Python demo code:
from multiprocessing import Pool, cpu_count
def add(x, y):
return x + y
def main():
# Create a pool with 4 worker processes
with Pool(cpu_count()) as pool:
# The arguments are passed as tuples
result = pool.starmap(add, [(1, 2), (3, 4), (5, 6), (7, 8), (1, 2), (3, 4), (5,6), (7, 8)])
print(result) # prints [3, 7, 11, 15]
if __name__ == '__main__':
main()
In window form, I created just a button and with a button click it calls python code. After execution produces multiple windows like this in the image attached.image after clicking button. I know it's happening due to of multiprocessing because I also tested it without a multiprocessing module and it worked fine. it displays windows as the value of cpu_count. suggest me something if anyone knows it. Thanks