Skip to main content

The Python Banyan Framework

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 that includes a User's Guide with hands-on examples, as well documentation for the OneGPIO Project 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.

It is being used by Palace Games 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, Ruby, and Java. 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.

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 logo

Metadata

Release files for python-banyan 3.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-banyan 3.17
File Size Uploaded
python_banyan-3.17.tar.gz 106.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-banyan 3.17
File Interpreter ABI Platform
python_banyan-3.17-py3-none-any.whl Python 3 none any Details

Total release size: 287.2 kB

Release files / python_banyan-3.17.tar.gz

Download URL python_banyan-3.17.tar.gz
Size 106.1 kB
Tags Source
SHA-256 checksum
How to use checksums
235aa86269e5fce7fa5f5b232cf508721358c9f7e510b2f59a5e1b4e7c403864
BLAKE2b-256 checksum
How to use checksums
f304431b0da6b307bd66f31aa75f2328ef81325fe5bb07f8267cbe7beb1004d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / python_banyan-3.17-py3-none-any.whl

Download URL python_banyan-3.17-py3-none-any.whl
Size 181.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06694cc64e3a5257b725094e1cabbd809f58fbac6c153b3bc81591aad69ce82e
BLAKE2b-256 checksum
How to use checksums
54f8941ff4043b10280e915f0e77cbe80543588f37d309db75310205586981b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

3.17 This release

2 release files

3.16

2 release files

3.14

2 release files

3.13

2 release files

3.12

2 release files

3.11

2 release files

3.10

2 release files

3.9

2 release files

3.8

2 release files

3.7

2 release files

3.6

2 release files

3.5

1 release file

3.4

1 release file

3.3

2 release files

3.2

2 release files

3.1

2 release files

3.0

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1

1 release file

2.0

1 release file

1.4

1 release file

1.03

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page