{"id":16977410,"url":"https://github.com/mryslab/python_banyan","last_synced_at":"2025-09-21T23:31:47.269Z","repository":{"id":41274810,"uuid":"77406786","full_name":"MrYsLab/python_banyan","owner":"MrYsLab","description":"A lightweight, reactive framework used to create flexible, non-blocking, event driven, asynchronous applications.","archived":false,"fork":false,"pushed_at":"2022-11-20T20:32:25.000Z","size":69134,"stargazers_count":71,"open_issues_count":0,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-29T20:51:34.961Z","etag":null,"topics":["asynchronous-applications","banyan-protocol-message","python3"],"latest_commit_sha":null,"homepage":"https://mryslab.github.io/python_banyan/#","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrYsLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-26T21:02:43.000Z","updated_at":"2024-04-19T10:38:56.000Z","dependencies_parsed_at":"2023-01-22T10:30:22.261Z","dependency_job_id":null,"html_url":"https://github.com/MrYsLab/python_banyan","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpython_banyan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpython_banyan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpython_banyan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpython_banyan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrYsLab","download_url":"https://codeload.github.com/MrYsLab/python_banyan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233806650,"owners_count":18733229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous-applications","banyan-protocol-message","python3"],"created_at":"2024-10-14T01:28:53.779Z","updated_at":"2025-09-21T23:31:41.919Z","avatar_url":"https://github.com/MrYsLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Python Banyan Framework\n![](https://github.com/MrYsLab/python_banyan/blob/master/images/BanyanTree.png)\n\n\nThe Python Banyan Framework is a lightweight, reactive framework used to\ncreate flexible, non-blocking, event driven, asynchronous applications.\n\nPython Banyan comes with [full documentation](https://mryslab.github.io/python_banyan/#)\n that includes a [User's Guide](https://mryslab.github.io/python_banyan/#users_guide/) \n with hands-on examples, as well documentation for the\n [OneGPIO Project](https://mryslab.github.io/python_banyan/#gpio_intro/) \n that allows you to quickly and easily build reusable GPIO projects for the\n Arduino, ESP-8266, and Raspberry Pi.\n\nBase class API's may be viewed [here.](https://htmlpreview.github.io/?https://github.com/MrYsLab/python_banyan/blob/master/html/python_banyan/index.html)\n\n\nIt is being used by [Palace Games](https://www.raspberrypi.org/blog/raspberry-pi-escape-room/)\nto concurrently monitor hundreds of real-time sensors and actuators.\n\n* Based on a network connected Publish/Subscribe model,  Banyan components publish \nuser defined protocol messages in the form of Python dictionaries.\n* A Banyan protocol message may contain Numpy data.\n* Applications may reside on a single computer or be distributed across \nmultiple computers without having to change source code.\n* Compatible Banyan Frameworks are available for [JavaScript](https://github.com/MrYsLab/js-banyan), [Ruby](https://github.com/MrYsLab/rb_banyan), and\n[Java](https://github.com/MrYsLab/javabanyan). Components written in any of these languages can interact with components of a differing language without modification.\n* Runs on Python 2 or Python 3 (recommended).\n\n\nTo install,  view the full [installation instructions.](https://mryslab.github.io/python_banyan/install/#installing-python-banyan_1)\n\nA Simple Banyan Echo Server:\n\n```\nimport sys\nfrom python_banyan.banyan_base import BanyanBase\n\n\nclass EchoServer(BanyanBase):\n    \"\"\"\n    This class is a simple Banyan echo server\n    \"\"\"\n    def __init__(self, ):\n\n        # initialize the parent\n        super(EchoServer, self).__init__(process_name='EchoServer')\n\n        # subscribe to receive 'echo' messages from the client\n        self.set_subscriber_topic('echo')\n\n        # wait for messages to arrive\n        try:\n            self.receive_loop()\n        except KeyboardInterrupt:\n            self.clean_up()\n            sys.exit(0)\n\n    def incoming_message_processing(self, topic, payload):\n        \"\"\"\n        Process incoming messages from the client\n        :param topic: message topic\n        :param payload: message payload\n        \"\"\"\n        # republish the message with a topic of reply\n        self.publish_payload(payload, 'reply')\n        \n        # extract the message number from the payload\n        print('Message number:', payload['message_number'])\n\n```\n\nA Simple Banyan Echo Client:\n\n```\nimport sys\nfrom python_banyan.banyan_base import BanyanBase\n\n\nclass EchoClient(BanyanBase):\n    \"\"\"\n    This is a simple echo client derived from the BanyanBase class. \n    It sends out a series of messages and expects an\n    echo reply from the server.\n    \"\"\"\n\n    def __init__(self):\n\n        # initialize the parent\n        super(EchoClient, self).__init__(process_name='EchoClient')\n\n        # accept banyan messages with the topic of reply\n        self.set_subscriber_topic('reply')\n\n        # sequence number of messages and total number of messages to send\n        self.message_number = self.number_of_messages = 10\n\n        # send the first message - make sure that the server is already started\n        self.publish_payload({'message_number': self.message_number}, 'echo')\n\n        # get the reply messages\n        try:\n            self.receive_loop()\n        except KeyboardInterrupt:\n            self.clean_up()\n            sys.exit(0)\n\n    def incoming_message_processing(self, topic, payload):\n        \"\"\"\n        Process incoming messages received from the echo client\n        :param topic: Message Topic string\n        :param payload: Message Data\n        \"\"\"\n\n        # When a message is received and its number is zero, finish up.\n        if payload['message_number'] == 0:\n            print(str(self.number_of_messages) + ' messages sent and received. ')\n            input('Press enter to exit.')\n            self.clean_up()\n            sys.exit(0)\n        # bump the message number and send the message out\n        else:\n            self.message_number -= 1\n            if self.message_number \u003e= 0:\n                self.publish_payload({'message_number': self.message_number}, 'echo')\n\n\n```\n\nThis project was developed with [Pycharm](https://www.jetbrains.com/pycharm/) ![logo](https://github.com/MrYsLab/python_banyan/blob/master/images/icon_PyCharm.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmryslab%2Fpython_banyan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmryslab%2Fpython_banyan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmryslab%2Fpython_banyan/lists"}