Adding a check to prevent event loop reentrant.