eio icon indicating copy to clipboard operation
eio copied to clipboard

unable to do open/write

Open wquockATblurb opened this issue 12 years ago • 1 comments

I try this

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

wquockATblurb avatar Apr 05 '12 04:04 wquockATblurb

figured out. need to do

EIO.open(path, EIO::CREAT|EIO::RDWR)

wquockATblurb avatar Apr 05 '12 18:04 wquockATblurb