Set flush timer in the event loop instead