Are there alternative mechanism(s) for creating a long-running process besides running an infinite loop?
The common pattern seems to be this:
while True:
# Check for some condition or waiting for some event
# Do some processing
time.sleep(0.01)
I am particularly interested in the scenario where the process acts as a worker that listens to some event (e.g. waiting on a task queue).
What are the performance characteristics of the alternative approaches?
Prior art on "wait for and process job" thing has been done a few different ways:
multiprocessing
andthreading
for some helpful primitives)