I\'m trying to run two functions simultaneously in Python. I have tried the below code which uses multiprocessing but when I execute the code, the second functi
This is just what i needed. I know it wasn't asked but i modified shashank's code to suit Python 3 for anyone else looking :)
from multiprocessing import Process
import sys
rocket = 0
def func1():
global rocket
print ('start func1')
while rocket < sys.maxsize:
rocket += 1
print ('end func1')
def func2():
global rocket
print ('start func2')
while rocket < sys.maxsize:
rocket += 1
print ('end func2')
if __name__=='__main__':
p1 = Process(target=func1)
p1.start()
p2 = Process(target=func2)
p2.start()
Substitute sys.maxsize for an number then print(rocket)and you can see it count up one at a time. Get to a number and stop