“IOError:[Errno 35]Resource temporary unavailable”包含PhantomJS、python、selenium、unittes

2024-10-02 02:29:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我在使用selenium和PhantomJS驱动程序运行单元测试时遇到了一个问题。它似乎与PhantomJS进程中stderr/stdout的资源争用有关。错误是:

$ python -m unittest selenium_failure.SeleniumTestCase
[]
[{u'timestamp': 1395857498698, u'message': u'{"log":{"version":"1.2","creator":{"name":"PhantomJS","version":"1.9.7"},"pages":[{"startedDateTime":"2014-03-26T18:11:38.347Z","id":"https://www.google.com/","title":"Google","pageTimings":{"onLoad":294}}],"entries":[{"startedDateTime":"2014-03-26T18:11:38.344Z","time":127,"request":{"method":"GET","url":"https://www.google.com/","httpVersion":"HTTP/1.1","cookies":[],"headers":[{"name":"User-Agent","value":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"},{"name":"Accept","value":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}],"queryString":[],"headersSize":-1,"bodySize":-1},"response":{"status":200,"statusText":"OK","httpVersion":"HTTP/1.1","cookies":[],"headers":[{"name":"Date","value":"Wed, 26 Mar 2014 18:11:37 GMT"},{"name":"Expires","value":"-1"},{"name":"Cache-Control","value":"private, max-age=0"},{"name":"Content-Type","value":"text/html; charset=UTF-8"},{"name":"Set-Cookie",E
======================================================================
ERROR: test_that_something_fails (selenium_failure.SeleniumTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "selenium_failure.py", line 16, in test_that_something_fails
    print repr(self.selenium.get_log('har'))
IOError: [Errno 35] Resource temporarily unavailable

----------------------------------------------------------------------
Ran 1 test in 2.398s

FAILED (errors=1)

更详细的要点是:https://gist.github.com/lucaswiman/9788422

^{pr2}$

这个错误在OSX操作系统上是可以重现的,但在Ubuntu12.04上却不能。我相信这并不是OSX特有的,因为在Ubuntu上运行的集成测试中我也看到过类似的错误,尽管我无法以独立的形式重现它。在

  • Python 2.7.6
  • 硒==2.35.0
  • 在幻影@1.9.7在

Tags: namehttpstestcomlogfailurevalueversion
1条回答
网友
1楼 · 发布于 2024-10-02 02:29:00

修好了!一位同事向我指出了这个相关的问题:http://trac.edgewall.org/ticket/2066#comment:1我修改了那里的补丁,使sys.__stderr__和{}具有块标志。在phantomjsWebDriver实例化后立即调用该函数,可以将stderr发送到stderr。在

相关问题 更多 >

    热门问题