I've been trying to run two infinitely looping functions parallel to each other with python, but just calling both functions on separate lines seems to not be working because the second function never actually gets called when I'm running the code.
Asked
Active
Viewed 35 times
0
-
1One thread runs procedural (one line after the other). You need multiple threads: https://docs.python.org/3/library/threading.html – jabaa Apr 11 '22 at 19:46
-
1https://stackoverflow.com/a/7207336/1401798 – Truefalse Apr 11 '22 at 19:48
-
@PranavHosangadi The question is about running two codes simultaneously. It's unclear if this means concurrently or parallel. – jabaa Apr 11 '22 at 19:53
-
@jabaa fair point. – Pranav Hosangadi Apr 11 '22 at 19:54
-
Looping sounds like a CPU bounded task. Maybe you want to take a look at concurrent.future ProcessPoolExecutor? – Vae Jiang Apr 11 '22 at 20:54
-
I would be running them parallel to each other – Ernie May Apr 13 '22 at 16:23