remote = True if remote: remote = RemoteConnection().start_listener("localhost", 0) remote.register("ping", actor_of(Ping)) remote.start_all() port = remote.listener.socket.port ping = RemoteConnection().actor_for("ping", "localhost", port) else: ping = actor_of(Ping) ping.start() pong = actor_of(Pong) pong.start() ping.notify("connect", [pong.uuid]) ping.notify("Start") pong.join() if remote: remote.stop() else: ping.stop() pong.stop()
def slow_series(self, message, *params): res = slow_series(*params) self.ref.reply(res) @expose def random_int(self, message): import random self.ref.reply(random.randint(0, 10)) actor = actor_of(ClientActor) actor.start() port = 50007 remote_actor = RemoteConnection().actor_for("main-actor", "localhost", port) res = remote_actor.query("multiply", [1, 2, 3, 4]) print res.get() remote_actor.notify("hello", [str(actor.uuid)]) try: while actor.is_alive: actor.join(1) except KeyboardInterrupt: print "Interrupted" actor.stop()