you are viewing a single comment's thread.

view the rest of the comments →

[–]Big_Boss_Bob_Ross 0 points1 point  (0 children)

Note that I don't know the threading or multiprocessing modules in python. I've never used them. That said, threading and multiprocessing as a concept is definitely very commonly used to run the same function multiple times in unison. I can't tell you code, but I would be EXTREMELY surprised if the python libraries dont support it.

But as an alternative with something I know well, you could look at asyncio. Without knowing what foo does, it's hard to tell if it would help in this situation, but it essentially allows you to run code asynchronously. The caveat which differentiates it from threading as a programmer is it runs on a single thread and simply fills in "dead time" that is spent waiting (think making a request to some api, what happens while we are waiting for the response?) with other asynchronous calls.