I have a function in a class which is activated by another .py
file. This function is just there to run simultaneously two other and distinct functions.
It works well on Ubuntu, but not on Windows. Is there any way to have the same result (could be with different code) on both system?
import multiprocessing
import time
class myClass:
def run_functions(self, var1):
self.p1 = multiprocessing.Process(target=self.first_function, args=[var1])
self.p2 = multiprocessing.Process(target=self.second_function)
self.p1.start()
self.p2.start()
def first_function(self, var1):
print('First function activated ' + var1)
time.sleep(2)
def second_function(self):
print('Second function activated')
x = myClass()
x.run_functions('10') #Normally activated from another .py file with a list
I don't mind using threading instead. It just needs to work!