我有一个协同程序,等待事件设置:
@cocotb.coroutine
def wb_RXDR_read(self):
""" waiting util RXDR is read """
if not self._RXDR_read_flag:
while True:
yield self._RXDR_read_event.wait()
break
我想在它上面«屈服»超时。为了做到这一点,我做了:
RXDR_timeout = Timer(250, units="us")
ret = yield [RXDR_timeout, self.wb_RXDR_read()]
if ret == RXDR_timeout:
self._dut._log.error("Timeout on waiting RXDR to be read")
raise TestError()
但我有个错误:
2ns ERROR Coroutine i2c_write yielded something the scheduler can't handle
Got type: <type 'list'> repr: [<cocotb.triggers.Timer object at 0x7f2098cb1350>, <cocotb.decorators.RunningCoroutine object at 0x7f2098cb1610>] str: [<cocotb.triggers.Timer object at 0x7f2098cb1350>, <cocotb.decorators.RunningCoroutine object at 0x7f2098cb1610>]
Did you forget to decorate with @cocotb.coroutine?
我的团队装饰有@协同程序. 如果我一个人放弃,那就行了:
yield self.wb_RXDR_read() # <- that works
但我不能把它列在清单上。有没有可能像unix select()那样将协程放在一个要阻止的列表中?还是保留触发类?你知道吗
好的,我找到了解决办法。事实上,协同程序不能像时装本身那样被触发。它应该首先作为一个线程启动,并且为了检测协同程序的结束,
.join()
方法必须放在yield列表中:要记住的是:
fork()
和join()
相关问题 更多 >
编程相关推荐