I'm trying to integrate multiprocessing into a project but I can't get it working. This is what I've got:
import time import winsound from multiprocessing import Process winsound.MessageBeep() def pr1(): while 1: winsound.MessageBeep() time.sleep(0.5) if __name__ == '__main__': p = Process(target=pr1, args=()) p.start() p.join() while 1: print('hey') but if I run it i hear only one beep and i want it to repeat. How do I get this done?
oke plan b, I've got this now and I only get correct:
import time import winsound from multiprocessing import Process def pr1(): while 1: winsound.MessageBeep() print('its working') time.sleep(0.5) if __name__ == '__main__': print('correct') p = Process(target=pr1, args=()) p.start() p.join() while 1: print('hey') So there is something wrong with with the creating of the process. Any ideas?
__name__ == '__main__':works?winsound.MessageBeep()? Can you see it printing something?print helloexample on the Python doc page to work. I've never used multiprocessing but I have used threading. Not sure if that would meet your needs, but it works rather well. tutorialspoint.com/python/python_multithreading.htm