0
我有這樣的測試。這個問題在評論中。龍捲風測試「ioloop正在關閉」運行時錯誤
@gen_test(timeout=10)
def test_handshake(self):
print "+++++++++ Test create_stream ++++++++++"
self.io_loop.current().spawn_callback(self.pool.process_base_channel)
strcmd = "{'cmd': 'crt_stream', 'p_id':'test_stream','redis_chan':'test_chan'}"
cmd = ast.literal_eval(strcmd)
yield self.pool.q.put(cmd)
yield self.pool.q.join()
self.assertIsInstance(self.pool.streams['test_stream'], Stream)
print "++++++++++ Test subscription ++++++++++++"
'''
If this blocks run in this function, it OK, but if I move
it to separate function, runtime error occurs.
'''
subscr = "{'cmd': 'sub2stream', 'stream_id':'test_stream','redis_chan':'test_broadcast', 'cols':'all' }"
cmd = ast.literal_eval(subscr)
#self.io_loop.current().spawn_callback(self.pool.process_base_channel)
yield self.pool.q.put(cmd)
@gen_test(timeout=10)
def test_next(self):
print "++++++++++ Test subscription ++++++++++++"
print "Test stream %s" % self.pool.streams['test_stream'].publish_list
#self.io_loop.current().spawn_callback(self.pool.process_base_channel)
# tried respawn callbac
subscr = "{'cmd': 'sub2stream', 'stream_id':'test_stream','redis_chan':'test_broadcast', 'cols':'all' }"
cmd = ast.literal_eval(subscr)
yield self.pool.q.put(cmd)
由於某些原因,test_handshake運行後self.io_loop變爲關閉狀態。不明白爲什麼。
在後臺運行的永遠是async-while(consumer)(self.pool.process_base_channel)。池在測試類的setup()中放置。所以,當一個測試關閉ioloop時,那會一直持續下去,並可能導致一些「uhoh」? – user3003873