breilly / fm-orchestrator

Forked from fm-orchestrator 4 years ago
Clone

3b8cdd3 Avoid deep recursion when handling a large queue of events

Authored and Committed by otaylor 2 years ago
    Avoid deep recursion when handling a large queue of events
    
    Because each event handler wrapper would call scheduler.run() at the end before
    returning, with a queue of 100 events to process we'd end up
    with:
    
     Event handler 1 wrapper
       scheduler.run()
         Event handler 2 wrapper
           scheduler.run()
             .....
                .... Event handler 100 wrapper
    
    Which would eventually exhaust the Python stack limit. Fix this by making scheduler.run()
    no-op if the scheduler is already processing the queue in the current thread.