From: Daniel DeLorme Date: 2010-05-19T08:24:42+09:00 Subject: Re: Asynchronous HTTP request Brian Candler wrote: > Daniel DeLorme wrote: >> Brian Candler wrote: >>> So you didn't want a Thread, but you'll happily use a Fiber... >> Well, yes, a Fiber is just a coroutine, nothing like a thread. > > Are you saying that a Fiber will return control to you when it blocks > due to lack of data on a socket, as well as when the Fiber explicitly > "yields"? What value does it return to you in the blocking case? Given that I just said a Fiber is nothing like a thread, I'm not sure how you got the idea that I'm saying Fibers behave like threads (yield control on IO) > So AFAICS, your code which thinks it can do work while the the HTTP > request is running, doesn't. Rather, the HTTP request is not sent at all > until the Fiber#resume is called, and at that point it will block as > necessary until the whole response is received. I didn't post that code without testing it. If you look at it a bit more carefully maybe you'll understand how it works. The HTTP request is sent after the first Fiber#resume but the fiber yields before attempting to read the response.