path = "/tmp/asyncdl.out"
file = nil
EM.run do
EIO.eventmachine_handler # let libeio notify when there's result callbacks to invoke
# file = File.new('/tmp/asyncdl.out', 'w')
# EIO.write(file.fileno, "buf contents: hello") do |b|
# EIO.close(file.fileno) { EM.stop_event_loop }
# end
EIO.open(path, EIO::APPEND) do |fd|
EIO.write(fd, "buf contents: hello") do |b|
EIO.close(fd) { EM.stop_event_loop }
end
end
end
but got
/Library/Ruby/Gems/1.8/gems/eio-0.1/lib/eio/eventmachine.rb:13:in `poll': Bad file descriptor (Errno::EBADF)
from /Library/Ruby/Gems/1.8/gems/eio-0.1/lib/eio/eventmachine.rb:13:in `notify_readable'
from /Library/Ruby/Gems/1.8/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run_machine'
from /Library/Ruby/Gems/1.8/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run'
from asyndl-eio.rb:21
I try this
but got