2021-02-24 18:39:14 +00:00
|
|
|
import trio
|
2020-02-10 17:08:14 +00:00
|
|
|
import tractor
|
|
|
|
|
|
|
|
|
|
|
|
async def assert_err():
|
|
|
|
assert 0
|
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
async with tractor.open_nursery() as n:
|
|
|
|
real_actors = []
|
|
|
|
for i in range(3):
|
|
|
|
real_actors.append(await n.start_actor(
|
|
|
|
f'actor_{i}',
|
2021-02-24 23:46:33 +00:00
|
|
|
enable_modules=[__name__],
|
2020-02-10 17:08:14 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
# start one actor that will fail immediately
|
2020-12-21 14:09:55 +00:00
|
|
|
await n.run_in_actor(assert_err)
|
2020-02-10 17:08:14 +00:00
|
|
|
|
|
|
|
# should error here with a ``RemoteActorError`` containing
|
|
|
|
# an ``AssertionError`` and all the other actors have been cancelled
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
try:
|
|
|
|
# also raises
|
2021-02-24 18:39:14 +00:00
|
|
|
trio.run(main)
|
2020-02-10 17:08:14 +00:00
|
|
|
except tractor.RemoteActorError:
|
|
|
|
print("Look Maa that actor failed hard, hehhh!")
|