diff --git a/chat.py b/chat.py index 4e36212..f51a220 100644 --- a/chat.py +++ b/chat.py @@ -12,6 +12,7 @@ conn_str = '' cap_str = '' cap = sturdy.SturdyRef.decode(syndicate.parse(cap_str)) +@actor.run_system(name = 'chat', debug = False) def main(turn): root_facet = turn._facet @@ -37,5 +38,3 @@ def main(turn): while line := (await reader.readline()).decode('utf-8'): actor.Turn.external(f, lambda turn: turn.send(ds, Says(me, line.strip()))) actor.Turn.external(f, lambda turn: turn.stop(root_facet)) - -actor.start_actor_system(main, name = 'chat', debug = False) diff --git a/syndicate/actor.py b/syndicate/actor.py index 667c39f..4bf6348 100644 --- a/syndicate/actor.py +++ b/syndicate/actor.py @@ -14,6 +14,10 @@ _next_actor_number = IdGenerator() _next_handle = IdGenerator() _next_facet_id = IdGenerator() +# decorator +def run_system(**kwargs): + return lambda boot_proc: start_actor_system(boot_proc, **kwargs) + def start_actor_system(boot_proc, debug = False, name = None, configure_logging = True): if configure_logging: logging.basicConfig(level = logging.DEBUG if debug else logging.INFO)