停止 cocotb 分叉协程
Stopping cocotb forked coroutine
我有一个等待信号上升的协程:
@cocotb.coroutine
def wait_for_rise(self):
yield RisingEdge(self.dut.mysignal)
我在我的 «main» 测试函数中启动它,就像这样:
mythread = cocotb.fork(wait_for_rise())
即使没有信号上升,我也想在一段时间后停止它。我试图“杀死”它:
mythread.kill()
但是异常发生了:
Send raised exception: 'RunningCoroutine' object has no attribute '_join'
File "/opt/cocotb/cocotb/decorators.py", line 121, in send
return self._coro.send(value)
File "/myproject.py", line 206, in i2c_read
wTXDRwthread.kill()
File "/opt/cocotb/cocotb/decorators.py", line 151, in kill
cocotb.scheduler.unschedule(self)
File "/opt/cocotb/cocotb/scheduler.py", line 453, in unschedule
if coro._join in self._trigger2coros:
是否有正确停止分叉协程的解决方案?
这看起来与 https://github.com/potentialventures/cocotb/issues/650 中的问题相同 - 您可以订阅该问题,以便在其状态发生变化时收到通知。
我有一个等待信号上升的协程:
@cocotb.coroutine
def wait_for_rise(self):
yield RisingEdge(self.dut.mysignal)
我在我的 «main» 测试函数中启动它,就像这样:
mythread = cocotb.fork(wait_for_rise())
即使没有信号上升,我也想在一段时间后停止它。我试图“杀死”它:
mythread.kill()
但是异常发生了:
Send raised exception: 'RunningCoroutine' object has no attribute '_join'
File "/opt/cocotb/cocotb/decorators.py", line 121, in send
return self._coro.send(value)
File "/myproject.py", line 206, in i2c_read
wTXDRwthread.kill()
File "/opt/cocotb/cocotb/decorators.py", line 151, in kill
cocotb.scheduler.unschedule(self)
File "/opt/cocotb/cocotb/scheduler.py", line 453, in unschedule
if coro._join in self._trigger2coros:
是否有正确停止分叉协程的解决方案?
这看起来与 https://github.com/potentialventures/cocotb/issues/650 中的问题相同 - 您可以订阅该问题,以便在其状态发生变化时收到通知。