2

これは、私たちが持っているより強力なプロダクションマシンでしか再現できない奇妙な回帰です。

def test_foo(self):
    res = self._run_job( ....)
    self.assertTrue("Hello Input!" in res.json()["stdout"], res.text)
    .........

def _run_job(self, cbid, auth, d):    
    .........
    while True:
        res = requests.get(URL+"/status/"+status_id, auth=auth)   <--- hangs here
        if res.json()["status"] != "Running":
            break
        else:
            time.sleep(2)
    ..........

プロセスを中断する必要があります。これがトレースバックです。

Traceback (most recent call last):
  File "test_full.py", line 231, in <module>
    unittest.main()
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/main.py", line 98, in __init__
    self.runTests()
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/main.py", line 232, in runTests
    self.result = testRunner.run(self.test)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/runner.py", line 162, in run
    test(result)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/suite.py", line 64, in __call__
    return self.run(*args, **kwds)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/suite.py", line 84, in run
    self._wrapped_run(result)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/suite.py", line 114, in _wrapped_run
    test._wrapped_run(result, debug)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/suite.py", line 116, in _wrapped_run
    test(result)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/case.py", line 398, in __call__
    return self.run(*args, **kwds)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/unittest2/case.py", line 340, in run
    testMethod()
  File "test_full.py", line 59, in test_session
    "cmd": "python helloworld.py"
  File "test_full.py", line 129, in _run_job
    time.sleep(2)
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/gevent/hub.py", line 79, in sleep
    switch_result = get_hub().switch()
  File "/opt/graphyte/vens/gcs/local/lib/python2.7/site-packages/gevent/hub.py", line 164, in switch
    return greenlet.switch(self)
KeyboardInterrupt
Exception KeyError: KeyError(155453036,) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored

なぜgevent関与するのですか?これは機能テストです。ライブラリを介してHTTPリクエストを行うだけなrequestsので、おそらくはswitchを参照しrequestsます。

しかし、単純なループであるため、これはどのように失敗する可能性がありますか?

4

2 に答える 2

1

なぜgevent関与するのですか?

ライブラリは、geventいくつかの標準モジュールにモンキーパッチを適用して、それらを協調させます。time.sleepによる置き換えgevent.sleepは、変更の1つです。

http://www.gevent.org/gevent.monkey.html#gevent.monkey.patch_time

于 2013-02-25T08:21:22.237 に答える
1

gevent でモンキー パッチを適用していますか?

ネットワーク要求をオンにして、何らかの理由で戻ってこない可能性があります。今のところサルのパッチをやめて、必要な場所にgeventを入れてください。

リクエストが非同期になったので、すぐに戻ってきて、(再び非同期で)スリープし、リクエストして、リンス/繰り返し...

于 2013-02-25T09:51:39.743 に答える