You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every so often, we get this RuntimeError when calling publish_async due to some as-yet unknown issue we're having with EventMachine+Passenger:
/gems/eventmachine-1.0.3/lib/em/connection.rb:619 in "set_pending_connect_timeout"
/gems/eventmachine-1.0.3/lib/em/connection.rb:619 in "pending_connect_timeout="
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:61 in "block in activate_connection"
/gems/eventmachine-1.0.3/lib/eventmachine.rb:672 in "bind_connect"
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:54 in "activate_connection"
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:89 in "setup_request"
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:8 in "post"
/gems/keen-0.7.7/lib/keen/http.rb:75 in "post"
/gems/keen-0.7.7/lib/keen/client/publishing_methods.rb:69 in "publish_async"
Sometimes the EM problem causes an error that the Keen gem catches and bubbles up as a Keen::Error:
Keen::Error: Keen IO Exception: An EventMachine loop must be running to use publish_async calls
/gems/keen-0.7.7/lib/keen/http.rb:53 in "initialize"
/gems/keen-0.7.7/lib/keen/client/publishing_methods.rb:66 in "new"
/gems/keen-0.7.7/lib/keen/client/publishing_methods.rb:66 in "publish_async"
I'd rather just catch the Keen::Error in my application code and not have to look out for the RuntimeError, too.
The text was updated successfully, but these errors were encountered:
@loren - thanks for opening the issue. There are rare cases where the EventMachine will die even if the process is still running. Since you've seen this in your app, I suggest adding some protection like this:
defensure_emunlessEventMachine.reactor_running? && EventMachine.reactor_thread.alive?Thread.new{EventMachine.run}sleep1endend# put this before callsensure_emKeen.publish_async(...)
This ensures that the loop is running before making the call. Alternatively you could catch the exception, restart em, and then try the call again. I'll look into the RuntimeError bubbling up, that's strange. Maybe a race condition.
Adding in a runtime error catch for Event Machine for the very rare chance that the Event Machine isn't running or stopped running.
Code taken from keenlabs/keen-gem#22
Every so often, we get this RuntimeError when calling publish_async due to some as-yet unknown issue we're having with EventMachine+Passenger:
/gems/eventmachine-1.0.3/lib/em/connection.rb:619 in "set_pending_connect_timeout"
/gems/eventmachine-1.0.3/lib/em/connection.rb:619 in "pending_connect_timeout="
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:61 in "block in activate_connection"
/gems/eventmachine-1.0.3/lib/eventmachine.rb:672 in "bind_connect"
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:54 in "activate_connection"
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:89 in "setup_request"
/gems/em-http-request-1.0.3/lib/em-http/http_connection.rb:8 in "post"
/gems/keen-0.7.7/lib/keen/http.rb:75 in "post"
/gems/keen-0.7.7/lib/keen/client/publishing_methods.rb:69 in "publish_async"
Sometimes the EM problem causes an error that the Keen gem catches and bubbles up as a Keen::Error:
Keen::Error: Keen IO Exception: An EventMachine loop must be running to use publish_async calls
/gems/keen-0.7.7/lib/keen/http.rb:53 in "initialize"
/gems/keen-0.7.7/lib/keen/client/publishing_methods.rb:66 in "new"
/gems/keen-0.7.7/lib/keen/client/publishing_methods.rb:66 in "publish_async"
I'd rather just catch the Keen::Error in my application code and not have to look out for the RuntimeError, too.
The text was updated successfully, but these errors were encountered: