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.