1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00
teampoltergeist--poltergeist/lib/capybara
Dmitry Vorotilin e4c7550083 Fix #382, #404 JRuby pending test
We grab all the output from PhantomJS (like console.log) in another thread and
when PhantomJS exits first as in related test when we send
`driver.browser.command('exit')` we will try to restart it. In order to do it we
stop server and client. We see this error `IOError: Stream closed` for the
client. It happens because JRuby tries to close pipe with
https://github.com/jruby/jruby/blob/jruby-1_7/core/src/main/java/org/jruby/RubyIO.java#L2067
which raises an error here
https://github.com/jruby/jruby/blob/jruby-1_7/core/src/main/java/org/jruby/RubyIO.java#L4753
It happens not just because IO was closed but because it was blocked on `eof?`
or `readpartial` call. As you can see the error will be raised in related thread
(it's not actually main thread but the thread that listens to the output) that's
why if you put some debug code after `rescue IOError` it won't be shown and in
fact the main thread will continue working after the raise. For instance:

    def restart
      stop
      start
    end

it will invoke `start` even if we have seen `IOError` in `stop` method because
the error has been raised in another thread. In order to fix it we don't have to
give a chance to block IO. `IO.select` shows that there's something to be read
in pipe.
2013-10-27 20:16:25 +04:00
..
poltergeist Fix #382, #404 JRuby pending test 2013-10-27 20:16:25 +04:00
poltergeist.rb Revert “Remove multi_json dependency” 2013-06-09 17:12:06 +03:00