On 4 ene, 19:30, i... / frogcottage.demon.co.uk wrote: > On 4 Jan, 15:35, James Tucker <jftuc... / gmail.com> wrote: > > > > > On 4 Jan 2008, at 11:14, Francis Cianfrocca wrote: > > > > ------=_Part_26026_29096075.1199459699490 > > > Content-Type: text/plain; charset=ISO-8859-1 > > > Content-Transfer-Encoding: 7bit > > > Content-Disposition: inline > > > > On Jan 4, 2008 10:01 AM, James Tucker <jftuc... / gmail.com> wrote: > > > >> STDIN.gets blocks hard on windows - that is, it blocks at the "c > > >> level" which blocks all running green threads. > > > >> The result is this 'lag' behavior - in fact what is happening > > >> normally > > >> is that you're not getting any running threads or socket reads except > > >> in the time between gets returning a value, and being called again. > > > >> If you avoid $stdin, you will find that the flow is smooth. > > > >> Oh, and $stdout blocks too... > > > >> There's a video here that sort of demonstrates this in a visual way: > > > >>http://blog.ra66i.org/wp-content/network_rotator_fun.swf > > > >> One side is an echo server, which reverses the string it echos, and > > >> the other is a generator, which generates strings with a moving # in > > >> them. "I" and "O" have meaning local to the respective application. > > >> The right hand side is the generator, the left hand side is the > > >> reversing echo server. > > > >> Those were actually built on top of EM, but it's the same issue you > > >> see. > > > > The generic answer that EM would provide is: "don't use threads at > > > all." > > > The video there doesn't use threads. That's a completely "native" EM > > stack that uses the protocol code I showed you a few weeks ago. In > > fact, it's the demo application I'll be releasing with that protocol. > > > With or without threads, the problem the OP was describing actually > > comes up anyway on Windows, as the console IO code could really do > > with being made non-blocking, like it is on *nix. My understanding is > > though, that this is non-trivial. > > > > Unfortunately, at the current time, there is a problem in EM's console > > > handler that makes event-driven keyboard input unre > > > lol, :-) - Is that me or you, or a joke? (the premature termination). > > > Hmm, Luis got it, looks like it was me, scary. *slaps* Mail.app. > > Hi thanks for the answers. I removed the stdin line and replaced it > with gets, and it still has the same error. I/O operations are blocking thread in 1.8 (this under Windows) > Can I take it Ruby Sockets don't work very well with windows? I commented that was a patch for rb_w32_select on ruby-core or rubyforge tracker but couldn't find it. I think like most of the patches hanging there, they get ignored. Maybe I should start learning japanesse and hang on ruby-dev ;-) Regards, -- Luis Lavena