Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing deferred tasks caught by EM.error_handler are run repeatedly #61

Closed
leekirchhoff opened this issue Mar 1, 2010 · 3 comments
Closed
Labels

Comments

@leekirchhoff
Copy link

If an EM.error_handler is introduced that does not call EM.stop (e.g., it just logs an error and allows EM.run loop to continue), a task that fails and is caught by this error_handler is run repeatedly and no other deferred tasks get run.

This is due to code in EventMachine#run_deferred_callbacks that does not remove callbacks from @next_tick_queue if there is a failure when executing the callback. This code failure is not caught in test_error_handler because the test error_handler calls EM.stop.

The run_deferred_callbacks method was patched as follows to fix this problem:

def self.run_deferred_callbacks
  until (@resultqueue ||= []).empty?
    result,cback = @resultqueue.pop
    cback.call result if cback
  end

  @next_tick_queue ||= []
  if (l = @next_tick_queue.length) > 0
    l.times { cback=@next_tick_queue.shift and cback.call }
  end
end
@paulhammond
Copy link

Testing this bug in EventMachine 1.0.0.beta.3 shows that this is no longer the case. EventMachine#run_deferred_callbacks now removes callbacks from the @next_tick_queue before calling them.

Unfortunately you get a different problem (as described in #185) but I think this bug as described is no longer an issue.

@dj2
Copy link
Contributor

dj2 commented May 11, 2011

@tmm1, anything left to do on this one?

@tmm1
Copy link
Contributor

tmm1 commented May 11, 2011

Closing.

@tmm1 tmm1 closed this as completed May 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants