# The Python Banyan Framework
![](https://github.com/MrYsLab/python_banyan/blob/master/images/BanyanTree.png)
The Python Banyan Framework is a lightweight, reactive framework used to
create flexible, non-blocking, event driven, asynchronous applications.
Python Banyan comes with [full documentation](https://mryslab.github.io/python_banyan/#)
that includes a [User's Guide](https://mryslab.github.io/python_banyan/#users_guide/)
with hands-on examples, as well documentation for the
[OneGPIO Project](https://mryslab.github.io/python_banyan/#gpio_intro/)
that allows you to quickly and easily build reusable GPIO projects for the
Arduino, ESP-8266, and Raspberry Pi.
Base class API's may be viewed [here.](https://htmlpreview.github.io/?https://github.com/MrYsLab/python_banyan/blob/master/html/python_banyan/index.html)
It is being used by [Palace Games](https://www.raspberrypi.org/blog/raspberry-pi-escape-room/)
to concurrently monitor hundreds of real-time sensors and actuators.
* Based on a network connected Publish/Subscribe model, Banyan components publish
user defined protocol messages in the form of Python dictionaries.
* A Banyan protocol message may contain Numpy data.
* Applications may reside on a single computer or be distributed across
multiple computers without having to change source code.
* Compatible Banyan Frameworks are available for [JavaScript](https://github.com/MrYsLab/js-banyan), [Ruby](https://github.com/MrYsLab/rb_banyan), and
[Java](https://github.com/MrYsLab/javabanyan). Components written in any of these languages can interact with components of a differing language without modification.
* Runs on Python 2 or Python 3 (recommended).
To install, view the full [installation instructions.](https://mryslab.github.io/python_banyan/install/#installing-python-banyan_1)
A Simple Banyan Echo Server:
```
import sys
from python_banyan.banyan_base import BanyanBase
class EchoServer(BanyanBase):
"""
This class is a simple Banyan echo server
"""
def __init__(self, ):
# initialize the parent
super(EchoServer, self).__init__(process_name='EchoServer')
# subscribe to receive 'echo' messages from the client
self.set_subscriber_topic('echo')
# wait for messages to arrive
try:
self.receive_loop()
except KeyboardInterrupt:
self.clean_up()
sys.exit(0)
def incoming_message_processing(self, topic, payload):
"""
Process incoming messages from the client
:param topic: message topic
:param payload: message payload
"""
# republish the message with a topic of reply
self.publish_payload(payload, 'reply')
# extract the message number from the payload
print('Message number:', payload['message_number'])
```
A Simple Banyan Echo Client:
```
import sys
from python_banyan.banyan_base import BanyanBase
class EchoClient(BanyanBase):
"""
This is a simple echo client derived from the BanyanBase class.
It sends out a series of messages and expects an
echo reply from the server.
"""
def __init__(self):
# initialize the parent
super(EchoClient, self).__init__(process_name='EchoClient')
# accept banyan messages with the topic of reply
self.set_subscriber_topic('reply')
# sequence number of messages and total number of messages to send
self.message_number = self.number_of_messages = 10
# send the first message - make sure that the server is already started
self.publish_payload({'message_number': self.message_number}, 'echo')
# get the reply messages
try:
self.receive_loop()
except KeyboardInterrupt:
self.clean_up()
sys.exit(0)
def incoming_message_processing(self, topic, payload):
"""
Process incoming messages received from the echo client
:param topic: Message Topic string
:param payload: Message Data
"""
# When a message is received and its number is zero, finish up.
if payload['message_number'] == 0:
print(str(self.number_of_messages) + ' messages sent and received. ')
input('Press enter to exit.')
self.clean_up()
sys.exit(0)
# bump the message number and send the message out
else:
self.message_number -= 1
if self.message_number >= 0:
self.publish_payload({'message_number': self.message_number}, 'echo')
```
This project was developed with [Pycharm](https://www.jetbrains.com/pycharm/) ![logo](https://github.com/MrYsLab/python_banyan/blob/master/images/icon_PyCharm.png)
Raw data
{
"_id": null,
"home_page": null,
"name": "python-banyan",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "python banyan, RPC, Remote Procedure Call, Event Driven, Asynchronous, Non-Blocking, Raspberry Pi, ZeroMQ, MessagePack, RedBot",
"author": null,
"author_email": "Alan Yorinks <MisterYsLab@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/2d/f3/cd95892f864424ce617c0fa37fe724bcf068acc88d41dd24b06afe9c06c5/python_banyan-3.16.tar.gz",
"platform": null,
"description": "# 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 >= 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",
"bugtrack_url": null,
"license": "AGPL-3.0-or-later",
"summary": "The Python Banyan Framework",
"version": "3.16",
"project_urls": null,
"split_keywords": [
"python banyan",
" rpc",
" remote procedure call",
" event driven",
" asynchronous",
" non-blocking",
" raspberry pi",
" zeromq",
" messagepack",
" redbot"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "33302482909869231ceecb655c7cf4c888ceec86d16df731dda5b213db78e356",
"md5": "e4b92cfd0f5ef879b08957f4cd4c67e3",
"sha256": "b957b2ac8f8644efe100137ad98cc79252458d7d7b4a091c54c7812fd3a31f61"
},
"downloads": -1,
"filename": "python_banyan-3.16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e4b92cfd0f5ef879b08957f4cd4c67e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 181002,
"upload_time": "2024-11-28T17:00:10",
"upload_time_iso_8601": "2024-11-28T17:00:10.508178Z",
"url": "https://files.pythonhosted.org/packages/33/30/2482909869231ceecb655c7cf4c888ceec86d16df731dda5b213db78e356/python_banyan-3.16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2df3cd95892f864424ce617c0fa37fe724bcf068acc88d41dd24b06afe9c06c5",
"md5": "c7dd5e47f9c25df64783893dfbea6cad",
"sha256": "2f9867a8bbbf37d33ae94c0f104caf3a0c139af2dc6c2d90fc465b107e16dbe6"
},
"downloads": -1,
"filename": "python_banyan-3.16.tar.gz",
"has_sig": false,
"md5_digest": "c7dd5e47f9c25df64783893dfbea6cad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 105729,
"upload_time": "2024-11-28T17:00:13",
"upload_time_iso_8601": "2024-11-28T17:00:13.020574Z",
"url": "https://files.pythonhosted.org/packages/2d/f3/cd95892f864424ce617c0fa37fe724bcf068acc88d41dd24b06afe9c06c5/python_banyan-3.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-28 17:00:13",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "python-banyan"
}