import asyncio from thespian.actors import * import time class EngActor(Actor): def __init__(self): self.greeting='hi there' def receiveMessage(self, message, sender): print(self.greeting) self.send(sender, self.greeting ) class KorActor(Actor): def __init__(self): self.greeting='안녕하시오' def receiveMessage(self, message, sender): time.sleep(1); print(self.greeting) self.send(sender, self.greeting ) class HelloAsync: def __init__(self): self.greeting = "hi there2" async def SayHello(self,message): await asyncio.sleep(1) print(self.greeting) #액터방식 def say_hello(): actorSys = ActorSystem() engActor = actorSys.createActor( EngActor ) korActor = actorSys.createActor( KorActor ) actorSys.tell(korActor, '이보시오~') actorSys.tell(engActor, 'are you there?') say_hello(); #코르틴 방식 async def asay_hello(): asyncHello = HelloAsync() await asyncHello.SayHello('are you there?') loop = asyncio.get_event_loop() loop.run_until_complete(asay_hello()) loop.close() print('============= wait for test ==================') time.sleep(3); ## Result - 순차적으로 처리된듯 하나~ 동시적으로 처리됨 # 안녕하시오 # hi there