-
Notifications
You must be signed in to change notification settings - Fork 425
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
Request interruption #492
Comments
The HTTP Client implementation doesn't know about thread interruptions. Is On Fri Jan 30 2015 at 9:03:54 AM Christian notifications@github.com wrote:
|
boost threads can be interrupted by calling "interrupt" on the thread object. That does not kill the thread it only sets an internal var to true, so that boost threads know thay have to quit. In the boost thread you have to call boost interruption points so the thread can handle this internal var and then the thread throws a "interrupt exception" its described in the boost documentation --> |
I think I know what's happening here -- is your httpClient declared in the same function that's being run in the thread? If it is, then that means exiting the function will cause it to destroy the httpClient object, and hence potentially cause the ongoing requests to hang. If the httpClient is shared among many threads, then that should allow the threads polling for Can you confirm that the httpClient object isn't declared in the same function? If it is, consider moving it out and sharing it across multiple threads (it should be thread-safe after all). |
indeed, this was the problem! If i now delete the class object where the thread is defined. it get stuck. i think its waiting for the request to finish in the destructor, but the request will maybee never finish. This are long polling requests which means they only return if there is some data to return. is there any way to destroy the client without have it waiting for the request? |
This is actually a limitation in the implementation of the client. :( I suspect it’s possible to make this happen, but I don’t have time to do it. Would you be interested in trying to implement this?
|
at least i can try it ;-) |
if i am running a client.get() in a boost thread like this
client::response httpResponse = httpClient.get(httpRequest);
while (!ready(httpResponse))
{
// doing stuff
boost::this_thread::interruption_point();
}
and i am calling "interrupt" on this thread. its getting not interrupted!
if i do a while loop and skip getting the request like this
while (true)
{
// doing stuff
boost::this_thread::interruption_point();
}
the interrupt works..
Bug? My Fault?
best regards
Chris
The text was updated successfully, but these errors were encountered: