Package: aplay
aplaypython actor model implement using asyncioInstallpip install aplayfrom 1.0.0 there is breaking change in apiUsageGet Startedimportsysimportosimportasyncioimportrandomfromaplay.kernel.actorimportActorfromaplay.kernel.systemimportKernelActorfromaplay.mailstation.simpleimportHashMailStationfromcollectionsimportdefaultdictfromcopyimportdeepcopyclassMonitor(Actor):def__init__(self,*args,**kwargs):super(Monitor,self).__init__(*args,**kwargs)self.count_num=defaultdict(int)self.displayer=self.create_actor(name="display",actor_cls=Displayer)asyncdefmsg_handler(self,msg=None):ifmsgisnotNone:msg_type=msg.get("msg_type")self.count_num[msg_type]+=1awaitself.displayer.tell(deepcopy(self.count_num))classDisplayer(Actor):asyncdefmsg_handler(self,msg=None):ifmsgisnotNone:print("-----monitor num----",msg)awaitself.send_to_address("/test",msg)classWorker(Actor):def__init__(self,*args,**kwargs):super(Worker,self).__init__(*args,**kwargs)self.worker_monitor=self.create_actor(name="count",actor_cls=Monitor)asyncdefmsg_handler(self,msg=None):print("worker--",msg)ifmsgisNone:returnelse:msg_type=msg.get("msg_type")ifmsg_type=="text":print("--text--",msg)else:# cc = 1 / 0print("--voice--",msg)awaitself.worker_monitor.tell(msg)classMyKernel(KernelActor):def__init__(self,name=None,mail_station=None,**kwargs):print(mail_station,kwargs)super(MyKernel,self).__init__(name=name,mail_station=mail_station,**kwargs)self.actor=self.create_actor(name="test",actor_cls=Worker)asyncdefmsg_handler(self,msg=None):print("mykernel",msg)foriinrange(100):tt=random.choice(["voice","text"])msg={"msg_type":tt,"content":f"hello{tt}{i}"}awaitself.send_to_address("/test",msg)bb=MyKernel("kernel",mail_station=HashMailStation())bb.tell_nowait("start")bb.start()and more you can refer to the example dirsyou can use it as a task queue and something else.if you dont want too heavy of celery or rq ,etcjust enjoy itinstructionsKernelActor means the kernel to start or daemon the whole program. 
it is only one process,you will have to use multiprocess if you want to utilize multi cores.

Actor is the basic class for worker actor and the kernel.

for worker actor ,you only need to inherit this class and define your funcion that needed.Actor Details in Tablepropertynamedescriptionuseage_nameactor's namefor identitify the actor_mail_stationactor's mail_stationthe place to send or receive msg and delivery msg_childactor's children (instances of actor)the actors start by itself_runing_stateactor's running statestate the running state of the actor_human_runing_statestopped by humanfor manually stop the actor and by default ,it cant be started by its parent_parentactor's parent actoractor's parent_addressthe actor's address that register in the mail stationmail address_loopactor's loopactor's loopfunctions need to inderitedfunction nameusagemustdescriptiondefaultdecide_to_startdecide to start itselfnotto decide itself start or not. actor can be in any state.  you can implement this function to make your own decisiononly human stopped state can prevent the actor starting.user_task_callbacktask done callbacknotthe callback of a task. can be with success and exception msg.do nothingprepare_childrenprepare to create or get the child actornotif you need child actor,you must inplement this, and add your child actor creator in heredo nothingprepare_mailboxprepare the mailboxnotif you want to define your own async mailbox or use redisMailboxdo nothingmsg_handlerthe working functionyesthe only funcion that really do the jobsnot Implementtipsactors are defined in class. you can create lots of actors in one actor.
but do not Circular create actors. 
such as you have a A_actor and B_actor,A_actor creates lots of B_actor, and B_actor creates lots of A_actor.

you can define lots of B_actor from A_actor with different names. and these actors can do lots of work based on different msg typeswhy this libthis lib intends to Decoupling the work flow using actor-like system,which utilize the asyncio to make work efficiently.we dont define the msg format just for you have the freedom to adjust to your program. it is you to guarantee your msg format's complete.the commong workflow issingle-forward, just as follows:say you have A-actor,B-actor,C-actor:A-actor work done then transfer msg to B-actor then to C-actor. no backwards.RequirementsPython_ 3.5+https://www.python.orgLicenseThe aplay is offered under AGPLV3 license.