{ "info": { "author": "aohan237", "author_email": "aohan237@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Software Development", "Topic :: Software Development :: Libraries" ], "description": "# aplay\n[![Downloads](https://pepy.tech/badge/aplay)](https://pepy.tech/project/aplay)\n[![PyPI version](https://badge.fury.io/py/aplay.svg)](https://badge.fury.io/py/aplay)\n![PyPI version](https://img.shields.io/pypi/pyversions/aplay)\n\n## **python actor model implement using asyncio**\n\n### Install\n\n--------------\n\npip install aplay\n\n**from 1.0.0 there is breaking change in api**\n\n### Usage\n\n#### Get Started\n\n```python\nimport sys\nimport os\nimport asyncio\nimport random\nfrom aplay.kernel.actor import Actor\nfrom aplay.kernel.system import KernelActor\nfrom aplay.mailstation.simple import HashMailStation\n\nfrom collections import defaultdict\nfrom copy import deepcopy\n\n\nclass Monitor(Actor):\n def __init__(self, *args, **kwargs):\n super(Monitor, self).__init__(*args, **kwargs)\n self.count_num = defaultdict(int)\n self.displayer = self.create_actor(name=\"display\", actor_cls=Displayer)\n\n async def msg_handler(self, msg=None):\n if msg is not None:\n msg_type = msg.get(\"msg_type\")\n self.count_num[msg_type] += 1\n await self.displayer.tell(deepcopy(self.count_num))\n\n\nclass Displayer(Actor):\n async def msg_handler(self, msg=None):\n if msg is not None:\n print(\"-----monitor num----\", msg)\n await self.send_to_address(\"/test\", msg)\n\n\nclass Worker(Actor):\n def __init__(self, *args, **kwargs):\n super(Worker, self).__init__(*args, **kwargs)\n self.worker_monitor = self.create_actor(name=\"count\", actor_cls=Monitor)\n\n async def msg_handler(self, msg=None):\n print(\"worker--\", msg)\n if msg is None:\n return\n else:\n msg_type = msg.get(\"msg_type\")\n if msg_type == \"text\":\n print(\"--text--\", msg)\n else:\n # cc = 1 / 0\n print(\"--voice--\", msg)\n await self.worker_monitor.tell(msg)\n\n\nclass MyKernel(KernelActor):\n def __init__(self, name=None, mail_station=None, **kwargs):\n print(mail_station, kwargs)\n super(MyKernel, self).__init__(name=name, mail_station=mail_station, **kwargs)\n self.actor = self.create_actor(name=\"test\", actor_cls=Worker)\n\n async def msg_handler(self, msg=None):\n print(\"mykernel\", msg)\n\n for i in range(100):\n tt = random.choice([\"voice\", \"text\"])\n msg = {\"msg_type\": tt, \"content\": f\"hello {tt} {i}\"}\n await self.send_to_address(\"/test\", msg)\n\n\nbb = MyKernel(\"kernel\", mail_station=HashMailStation())\nbb.tell_nowait(\"start\")\nbb.start()\n```\n\nand more you can refer to the example dirs\n\nyou can use it as a task queue and something else.if you dont want too heavy of celery or rq ,etc\n\njust enjoy it\n\n#### instructions\n\n KernelActor means the kernel to start or daemon the whole program. \n it is only one process,you will have to use multiprocess if you want to utilize multi cores.\n\n Actor is the basic class for worker actor and the kernel.\n\n for worker actor ,you only need to inherit this class and define your funcion that needed. \n\n#### Actor Details in Table\n\n##### property\nname|description|useage\n-|-|-\n_name|actor's name|for identitify the actor\n_mail_station|actor's mail_station|the place to send or receive msg and delivery msg\n_child|actor's children (instances of actor)|the actors start by itself\n_runing_state|actor's running state|state the running state of the actor\n_human_runing_state|stopped by human|for manually stop the actor and by default ,it cant be started by its parent\n_parent|actor's parent actor|actor's parent\n_address|the actor's address that register in the mail station| mail address\n_loop|actor's loop|actor's loop\n\n##### functions need to inderited\n\nfunction name|usage|must|description|default\n-|-|-|-|-\ndecide_to_start|decide to start itself|not| to decide itself start or not. actor can be in any state. you can implement this function to make your own decision|only human stopped state can prevent the actor starting.\nuser_task_callback|task done callback|not|the callback of a task. can be with success and exception msg. | do nothing\nprepare_children|prepare to create or get the child actor|not|if you need child actor,you must inplement this, and add your child actor creator in here| do nothing\nprepare_mailbox|prepare the mailbox|not| if you want to define your own async mailbox or use redisMailbox|do nothing\nmsg_handler|the working function|yes|the only funcion that really do the jobs| not Implement\n\n##### tips\n actors are defined in class. you can create lots of actors in one actor.\n but do not Circular create actors. \n 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.\n\n 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 types\n\n### why this lib\n\nthis lib intends to Decoupling the work flow using actor-like system,which utilize the asyncio to make work efficiently.\n\nwe 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.\n\nthe commong workflow is **single-forward**, just as follows:\n\nsay you have A-actor,B-actor,C-actor:\n\nA-actor work done then transfer msg to B-actor then to C-actor. no backwards.\n\n\nRequirements\n------------\n\n* Python_ 3.5+ https://www.python.org\n\nLicense\n-------\n\nThe aplay is offered under AGPLV3 license.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aohan237/aplay", "keywords": "", "license": "GNU AGPLv3", "maintainer": "", "maintainer_email": "", "name": "aplay", "package_url": "https://pypi.org/project/aplay/", "platform": "POSIX", "project_url": "https://pypi.org/project/aplay/", "project_urls": { "Homepage": "https://github.com/aohan237/aplay" }, "release_url": "https://pypi.org/project/aplay/1.1.1/", "requires_dist": [ "aioredis", "psutil", "msgpack" ], "requires_python": "", "summary": "asyncio actor model implemention for easy use", "version": "1.1.1", "yanked": false, "yanked_reason": null }, "last_serial": 12571436, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "da28884853e7cc4ae5d0393f9a551e4b", "sha256": "817caeacc480f16152b755cfe41dae513268234957034c2c77e4b2a7adb61b34" }, "downloads": -1, "filename": "aplay-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "da28884853e7cc4ae5d0393f9a551e4b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8380, "upload_time": "2018-12-10T07:39:06", "upload_time_iso_8601": "2018-12-10T07:39:06.953986Z", "url": "https://files.pythonhosted.org/packages/45/e7/de56e734fad92361936726496a4d2752e5758e2419ab3f06df90c3cd23b3/aplay-0.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "191a302764a5404f50e0ee0229242d69", "sha256": "82e368e386eaedc0573cc39de53f5537f8a7a0ad8f004430ab1eff553301daae" }, "downloads": -1, "filename": "aplay-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "191a302764a5404f50e0ee0229242d69", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9219, "upload_time": "2018-12-13T08:09:43", "upload_time_iso_8601": "2018-12-13T08:09:43.714464Z", "url": "https://files.pythonhosted.org/packages/fe/00/9a277e1ce6b18a4e734c2b0da88f885b73191bc4e11851111356e9f38d0c/aplay-0.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "fb1c37fb46baf2c4821030349b0456dc", "sha256": "36329cc70f60a6a0aa4d9b4949096aa3bb0eac621c3aa45f1134c8bebd9ad4a0" }, "downloads": -1, "filename": "aplay-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "fb1c37fb46baf2c4821030349b0456dc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9292, "upload_time": "2018-12-17T02:27:36", "upload_time_iso_8601": "2018-12-17T02:27:36.231540Z", "url": "https://files.pythonhosted.org/packages/5d/97/6df8343bf0dddb420ca806c87a8efcd2f4c084904c0af87873c86780a50c/aplay-0.1.2-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "89e37c521f34ff9a9436361b8b1d1cb3", "sha256": "2b932fc3b19d1ea0473157803aa5919b781b763af316665515d03393af925db5" }, "downloads": -1, "filename": "aplay-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "89e37c521f34ff9a9436361b8b1d1cb3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9371, "upload_time": "2019-01-14T08:21:52", "upload_time_iso_8601": "2019-01-14T08:21:52.167920Z", "url": "https://files.pythonhosted.org/packages/0c/cc/1dd2fcc04d6f146e9cf65d4875d03f33976cd763e06c64b20e2456ea505c/aplay-0.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "6067976aa1ad465316df60476f6805f3", "sha256": "8202bce004e5aa59912b1dad3d83ec9b5141bb62fde190a91936087ee15e53ca" }, "downloads": -1, "filename": "aplay-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "6067976aa1ad465316df60476f6805f3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10973, "upload_time": "2019-01-28T10:27:22", "upload_time_iso_8601": "2019-01-28T10:27:22.517600Z", "url": "https://files.pythonhosted.org/packages/60/a9/697d2d787cbae6c57c8ba3e08c6ddff11d51823e5366665a4bf4bbaff38c/aplay-0.1.5-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "ecd20007e148bf84865ea8fa5d09987d", "sha256": "e5adc4815f78c40e660b1e0d1fcb51fe578004d5ebab6d8ec6ad161519198df5" }, "downloads": -1, "filename": "aplay-0.1.6-py3-none-any.whl", "has_sig": false, "md5_digest": "ecd20007e148bf84865ea8fa5d09987d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11241, "upload_time": "2019-03-22T08:20:51", "upload_time_iso_8601": "2019-03-22T08:20:51.536607Z", "url": "https://files.pythonhosted.org/packages/71/32/c8ea91f731d3809e3bfa9591efe707ad2fff5245b54fc1d4dfa0ebb1a856/aplay-0.1.6-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "137e78a6f677c0c60a0f14ca5edad1f4", "sha256": "c9ad24c6f1ff146ec24b552245796659a4c17e2f24e4d985441af8d6ea36fc19" }, "downloads": -1, "filename": "aplay-0.1.7-py3-none-any.whl", "has_sig": false, "md5_digest": "137e78a6f677c0c60a0f14ca5edad1f4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11271, "upload_time": "2019-03-25T10:21:08", "upload_time_iso_8601": "2019-03-25T10:21:08.816547Z", "url": "https://files.pythonhosted.org/packages/83/86/ddb61bff5ff57814800e319ce9d137add55ff8afda6cb96a8e470b443ff4/aplay-0.1.7-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "a7d79433519dd09f082f286b12bc4061", "sha256": "120def95c164d0f587c3871a20db36f26836faf4eb810567b54985e7084ff873" }, "downloads": -1, "filename": "aplay-0.1.8-py3-none-any.whl", "has_sig": false, "md5_digest": "a7d79433519dd09f082f286b12bc4061", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11269, "upload_time": "2019-03-25T10:44:48", "upload_time_iso_8601": "2019-03-25T10:44:48.178124Z", "url": "https://files.pythonhosted.org/packages/0d/ad/784f7edb189bb34c048f52efbea4fdec6e00316bf6a1918fc6bb882eff5a/aplay-0.1.8-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "52ee66bb9216a6f6979a88d5149e4e4b", "sha256": "aa577f2ff8905f2748c7f5f98ef0078f4b9c716f56666d2fd7827349e17ee4cc" }, "downloads": -1, "filename": "aplay-0.1.9-py3-none-any.whl", "has_sig": false, "md5_digest": "52ee66bb9216a6f6979a88d5149e4e4b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11271, "upload_time": "2019-03-26T06:12:09", "upload_time_iso_8601": "2019-03-26T06:12:09.115121Z", "url": "https://files.pythonhosted.org/packages/c2/73/4ae51eb1e56310c77ce00ba7cbf3348db8daff904ad069133e174b33db70/aplay-0.1.9-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "7df88b7afa8679f34eadc4ebd66346a8", "sha256": "f6c26ef329fa12c0fd6ee161323eca0b53d22892500abb9ba0f9d23ed78be331" }, "downloads": -1, "filename": "aplay-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7df88b7afa8679f34eadc4ebd66346a8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11299, "upload_time": "2019-04-02T06:15:30", "upload_time_iso_8601": "2019-04-02T06:15:30.530053Z", "url": "https://files.pythonhosted.org/packages/f3/a9/53e76708513850c98d72a91b36f985c840def2fc8557642a61e7e17039ab/aplay-0.2.0-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "6288f6803f6db65580b3be3ceaf455b9", "sha256": "ea4820b928cf9da999e11209a9664e0cd8c67a6e5d52c773a57dd6575cfd5cff" }, "downloads": -1, "filename": "aplay-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6288f6803f6db65580b3be3ceaf455b9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12172, "upload_time": "2019-05-22T08:38:39", "upload_time_iso_8601": "2019-05-22T08:38:39.667444Z", "url": "https://files.pythonhosted.org/packages/66/16/462b857b88d1aac2d83abe77e2425b5e61763ea6881e6bbac776f11eaf8a/aplay-0.2.1-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "f7730e6b9acfec85049c8b5f6640c185", "sha256": "ad205e9f10bc782e45916358124096b6baacda56353a2e7884f37141ab0b0f49" }, "downloads": -1, "filename": "aplay-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "f7730e6b9acfec85049c8b5f6640c185", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12567, "upload_time": "2019-06-14T08:26:53", "upload_time_iso_8601": "2019-06-14T08:26:53.594791Z", "url": "https://files.pythonhosted.org/packages/60/1d/5e9ffad8afdb85b81e281ee4304566288e62f5dd26bd831c584a24b8b187/aplay-0.2.2-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "a384f2aa71272655440025da4892e60b", "sha256": "1b59814a67731321fefa8e416fa87f90224e1a619f16a5dd927cae7b194823dc" }, "downloads": -1, "filename": "aplay-0.2.3-py3-none-any.whl", "has_sig": false, "md5_digest": "a384f2aa71272655440025da4892e60b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12599, "upload_time": "2019-10-20T09:11:27", "upload_time_iso_8601": "2019-10-20T09:11:27.636428Z", "url": "https://files.pythonhosted.org/packages/b4/6d/69a3b0f0cf579e70fcd25be08ff6d60983fe1eb119c68eb69101c67cee15/aplay-0.2.3-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "01883efca1710c5b764cba885faf0a18", "sha256": "277e1763ac46cf0c2dec2df9b6dcd7fd8c32e63ddb4f17e360d04d92b11bbf83" }, "downloads": -1, "filename": "aplay-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "01883efca1710c5b764cba885faf0a18", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13818, "upload_time": "2019-10-22T03:48:50", "upload_time_iso_8601": "2019-10-22T03:48:50.854784Z", "url": "https://files.pythonhosted.org/packages/24/c4/e60dec760634e0f36c297b9407d81e97ec107065b3185bdb09a43716000a/aplay-0.3.0-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "24d8607b5278fa6c532b1206688697f2", "sha256": "557b905e801ae78310d51a91cc6e90298d9c82ab9f60d34bceacd3bf7da54826" }, "downloads": -1, "filename": "aplay-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "24d8607b5278fa6c532b1206688697f2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28067, "upload_time": "2022-01-10T03:27:41", "upload_time_iso_8601": "2022-01-10T03:27:41.402438Z", "url": "https://files.pythonhosted.org/packages/89/46/8ee359b22ac36443d12b9fd82b4b5312e35504aa175c31ff8ca58a613520/aplay-1.0.1-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "0a91a4f69e1d746e410b054586b54d48", "sha256": "b0ea75ac8eea3523ff388b39269ee31e437f93437818feca1d30e175852e2c49" }, "downloads": -1, "filename": "aplay-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0a91a4f69e1d746e410b054586b54d48", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28083, "upload_time": "2022-01-14T07:09:06", "upload_time_iso_8601": "2022-01-14T07:09:06.101997Z", "url": "https://files.pythonhosted.org/packages/fd/4b/f5730e837b602b06ff48f737f9307fea6deebda0967725874c997fd62e48/aplay-1.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0a91a4f69e1d746e410b054586b54d48", "sha256": "b0ea75ac8eea3523ff388b39269ee31e437f93437818feca1d30e175852e2c49" }, "downloads": -1, "filename": "aplay-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0a91a4f69e1d746e410b054586b54d48", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28083, "upload_time": "2022-01-14T07:09:06", "upload_time_iso_8601": "2022-01-14T07:09:06.101997Z", "url": "https://files.pythonhosted.org/packages/fd/4b/f5730e837b602b06ff48f737f9307fea6deebda0967725874c997fd62e48/aplay-1.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }