made event loop exception safe