SeleniumHQ/selenium — pull request #119 by jaminben (2013-09-22 18:25:34+00:00)
Title: Nosetests + PhantomJs webdriver generates IOError: [Errno 35] Resource temporarily unavailable on OSX

Minimal example:
```
from selenium import webdriver
driver = webdriver.PhantomJS()

def test_func():
print "x" * 1024*10
assert False
```

Results in:
```
Bens-MacBook-Pro-2:unittest-test bc$ nosetests selenium_test.py
F
======================================================================
FAIL: selenium_test.test_func
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 186, in runTest
self.test(*self.arg)
File "/Users/bc/olark/unittest-test/selenium_test.py", line 6, in test_func
assert False
AssertionError:
-------------------- >> begin captured stdout << ---------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTraceback (most recent call last):
File "/usr/local/bin/nosetests", line 9, in
load_entry_point('nose==0.11.3', 'console_scripts', 'nosetests')()
File "/Library/Python/2.7/site-packages/nose/core.py", line 117, in __init__
**extra_args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/Library/Python/2.7/site-packages/nose/core.py", line 196, in runTests
result = self.testRunner.run(self.test)
File "/Library/Python/2.7/site-packages/nose/core.py", line 63, in run
result.printErrors()
File "/Library/Python/2.7/site-packages/nose/result.py", line 96, in printErrors
_TextTestResult.printErrors(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 118, in printErrors
self.printErrorList('FAIL', self.failures)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 125, in printErrorList
self.stream.writeln("%s" % err)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 32, in writeln
self.write(arg)
IOError: [Errno 35] Resource temporarily unavailable
```

It looks like phantomJS might end up closing STDIN in the parent process, since subprocess was sharing FD when phantomJS was launched. This causes FD 0 to be reused, which I believe has a smaller buffer size, leading to the IOError: [Errno 35] when writing big strings. Fix is attached.