Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions amaranth/sim/_pycoro.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,23 @@ def run(self):
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)
Expand Down Expand Up @@ -118,10 +129,6 @@ def run(self):
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
1 change: 0 additions & 1 deletion tests/test_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ def process():
with self.assertRaisesRegex(TypeError,
r"Received unsupported command 1 from process .+?"):
yield 1
yield Settle()
survived = True
sim.add_process(process)
self.assertTrue(survived)
Expand Down