sim: fix simulation loop when process catches an injected exception.
This commit is contained in:
parent
15b6068c57
commit
f48b8650c4
|
@ -59,12 +59,23 @@ class PyCoroProcess(BaseProcess):
|
|||
self.clear_triggers()
|
||||
|
||||
response = None
|
||||
exception = None
|
||||
while True:
|
||||
try:
|
||||
command = self.coroutine.send(response)
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue