Francis Cianfrocca
2007-Jun-12 18:27 UTC
[Eventmachine-talk] Popen implemented, give it a try
Thanks to Bill Kelly for a lot of suggestions and a lot of research. You can now do this: module MyHandler def receive_data data puts data end def unbind puts "Unbound" end end EM.run { EM.popen "ls -ltr", MyHandler } EventMachine#popen runs the given command in a subprocesses connected to the main reactor loop with a full-duplex socketpair. Use EventMachine::Connection#get_pid to get the kernel PID of the subprocess in case you need it. The handler module or class works just like any other. You can imagine that you''re connected to a TCP server. Nothing is different. Good luck and if you try it, please leave feedback here. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070612/6857a3b4/attachment.html
From: Francis Cianfrocca> > module MyHandler > def receive_data data > puts data > end > def unbind > puts "Unbound" > end > end > > EM.run { > EM.popen "ls -ltr", MyHandler > } >Thanks, Francis !! This will be ideal for my current project. Regards, Bill