PYNQ
PYNQ copied to clipboard
Interrupting an interrupt wait leaves event dangling
I have the following code, which waits on an interrupt:
import asyncio
async def print_count():
while True:
await count.ap_return.wait()
a = count.register_map.cntr
print(a)
count.ap_return.event.clear()
if int(a) == 0:
return
loop = asyncio.get_event_loop()
loop.run_until_complete(print_count())
This works just fine, printing out the counter whenever the interrupt fires. However, if I interrupt this cell while it is executing, the next time I run the cell, I get double output, as if two events are being received. The problem compounds the more I interrupt the cell. I have to restart the kernel to clear the problem.
Is there a better way for me or for the Pynq library to be managing this resource?