Baby's First Parallel Processing
Hi! I'm pretty new to python.. Let's say I have the following program:
def isEqual(inputNumber):
if inputNumber == 69690696:
return True
else:
return False
toCheck = 0
while True:
if isEqual(toCheck):
break
toCheck += 1
Is there a way to change my while loop to run isEqual in parallel, until a thread returns true? I've looked at using multiprocessing.pool and apply_async, but it doesn't seem to do what I want it to do. Any help would be appreciated! ^^
Posted Dec 14, 2020, 2:30 AM UTC
Create a pipe between the processes - you can send a termination signal via the pipe.
Also, your function can be shortened to: