sim: fix simulation loop when process catches an injected exception.

This commit is contained in:
Wanda 2024-02-06 19:43:47 +01:00 committed by Catherine
parent 15b6068c57
commit f48b8650c4
2 changed files with 14 additions and 8 deletions

View file

@ -59,12 +59,23 @@ class PyCoroProcess(BaseProcess):
self.clear_triggers()
response = None
exception = None
while True:
try:
if exception is None:
command = self.coroutine.send(response)
else:
command = self.coroutine.throw(exception)
except StopIteration:
self.passive = True
self.coroutine = None
return
try:
if command is None:
command = self.default_cmd
response = None
exception = None
if isinstance(command, ValueCastable):
command = Value.cast(command)
@ -118,10 +129,6 @@ class PyCoroProcess(BaseProcess):
raise TypeError("Received unsupported command {!r} from process {!r}"
.format(command, self.src_loc()))
except StopIteration:
self.passive = True
self.coroutine = None
return
except Exception as exn:
self.coroutine.throw(exn)
response = None
exception = exn

View file

@ -685,7 +685,6 @@ class SimulatorIntegrationTestCase(FHDLTestCase):
with self.assertRaisesRegex(TypeError,
r"Received unsupported command 1 from process .+?"):
yield 1
yield Settle()
survived = True
sim.add_process(process)
self.assertTrue(survived)