ParallelCurl icon indicating copy to clipboard operation
ParallelCurl copied to clipboard

Calling startRequest() from within callback - infinite loop

Open joehoyle opened this issue 13 years ago • 2 comments

Hey, great library!

Hoever, I found if you call addRequest from with a callback you get a infinite loop, as the outstanding_requests is not removed until the callback function has returned. If you were to switched this around, so the outstanding_requests is unset beforehand, it would allow addRequest then finishAllRequests to be called within the callback function.

I have modified this locally, I can send it as a p/r if you wish.

Thanks

joehoyle avatar Sep 06 '12 18:09 joehoyle

Thanks Joe! I appreciate it, and a pull request would be handy, and I'll check it over when I have a chance. One pattern I've used in the past is creating a new ParallelCurl object from within the request callback, but I can see why your case is useful.

petewarden avatar Sep 09 '12 00:09 petewarden

@petewarden yeah I had considered that, though I am using a layer of abstraction in for the form of a HTTP_Requester class, which does some other boilerplate stuff, so access the same ParallelCurl request was more simple in that case. I'll open a p/r

joehoyle avatar Sep 10 '12 09:09 joehoyle