-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Provide method to register async shutdown function #613
Provide method to register async shutdown function #613
Conversation
Looking further info this, we might not need this new method. We could instead modify the existing client registerShutdownFunction() method, allowing it to be run more than once. It needs to run more than once anyways, so I'm not sure why it has this limitation :) |
You should not register it more than once, or you would handle the shutdown multiple times. |
The Raven_CurlHandler::join() method runs 4 times:
So I don't think there's anything wrong with registering it more than once :) |
Since there is no official method to register the shutdown handler that async requires - aside from Client::install() - my current workaround is this:
|
…send fatal error via curl async)
707a3d1
to
515831d
Compare
register_shutdown_function(array($this, 'onShutdown')); | ||
} | ||
$this->_shutdown_function_has_been_set = true; | ||
register_shutdown_function(array($this, 'onShutdown')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the if
removed here? If we can prevent it we should not add all the shutdown handlers...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using curl async, we need to register the shutdown function a second time, so that it runs after the fatal error handler.
$this->_curl_handler->registerShutdownFunction(); | ||
} | ||
// Register final shutdown function to send fatal error via curl async. | ||
$this->registerShutdownFunction(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the if here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not necessary, but the idea here was that this would be the suggested way to register shutdown function - given that _curl_handler is protected, this line is useful for anyone who is writing custom code and wants to reproduce the functionality of the install() method.
I'm not sure why we should not "protect" it from running more than once. Seems sensible to only register it when needed and only once. No need to register the same handler multiple times. Fine with making it a public method, also needs some documentation maybe when |
See my comment on June 15 - we are already calling Raven_CurlHandler::join() four times. This is re: number 3 in my June 15 comment - we need to register the shutdown function again when handling fatal errors with curl async, so that they can be sent after the fatal error is handled. It should be possible to refactor things so that shutdown functions run as few times as possible - the problem is that it's running too early, making an additional call necessary. Calling registerShutdownFunction() in install() could perhaps replace the other ways that shutdown handlers are being registered? I wasn't really trying for a major refactoring here, just trying to provide a public method that works, but refactoring would be nice. |
Heads up, I changed the base to |
Closing this as |
For any custom setups of the client that don't call install(), we should provide a method to register the async shutdown function (_curl_handler is protected so otherwise this can't be done).