Skip to main content

Multithreading supported python package for publisher and subscriber model.

Project description

Subpubpy

Motivation

At the time of creating high level application, programmers usually shares data between the instances. Sometimes there are situations where we need to parse same data in multithreading or even multiprocessing, which is very tedious process. At that moments, subpubpy becomes a pioneer and works efficiently even for large applications.

Description

  • pub: Each classes have a method pub which refers to the term publish. So, pub is a method which is used to publish any message to the all subscribers events.
def pub(self, event: str, payload: Any, verbose: bool = True) -> None:
        """Publishes the events.

        Parameters:
        -----------
        event: str
            event which need to be published.

        payload: Any
            Any kind of data structure to handle with event.

        verbose: Optional[bool]
            used for logging purpose if False no log message are passed.
        """

pub requires two parameters, event name of the event and other is payload a message for all the subscribers. There is a third parameter verbose which is used to log [DEBUG] messages which is produced by the pub. If verbose is False means don't output log message else output message in logs.

  • sub: Each classes have a method sub which referes to the term subscribe. So, sub is a method which is used to subscribe a event.
def sub(self, event: str, callback: Callable[[str, Any], None], verbose: bool = True) -> Union[
        None, TypeError]:
        """Subscribes event with callback.\n
        Here it checks if callback is not callable then raises TypeError \n
        else returns None.

        Parameters:
        -----------
        event: str
            event which need to be subscribe.

        callback: Callable
            callback must be callable function.

        verbose: Optional[bool]
            used for logging purpose if False no log message are passed.
        """

sub requires two parameters, event name of the event and other is callback a function which is called when some publishes a message which takes two parameters -> event, paylaod. There is a third parameter verbose which is used to log [DEBUG] messages which is produced by the pub. If verbose is False means don't output log message else output message in logs.

  • unsub: Each classes have a method unsub which referes to the term unsubscribe. So, sub is a method which is used to unsubscribe a event.
def unsub(self, event: str, handler: Any, verbose: bool = True) -> Union[None, ValueError]:
        """Unsubscribes event with callback.\n
        Unsubscribe checks callback is assigned to event else raise ValueError.

        Parameters:
        -----------
        event: str
            event which need to be subscribe.

        hanlder: Any
            remove handler from the system.

        verbose: Optional[bool]
            used for logging purpose if False no log message are passed.
        """

unsub requires two parameters, event name of the event and other is callback a function which is called when some publishes a message which takes two parameters -> event, paylaod. There is a third parameter verbose which is used to log [DEBUG] messages which is produced by the pub. If verbose is False means don't output log message else output message in logs.

API

SimpleSubpub:

Simple publish subscriber model which works under the main thread.

ThreadSafeSubpub:

Thread safe publish subscriber model which works under multithreading concept.

RegexSubpub:

Publish subscriber model which works under the main thread with regular expressions.

ThreadSafeRegexSubpub:

Thread safe publish subscriber model which works under multithreading concept and regular expression.

If you find any issue please feel free to report that issue on github

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subpubpy-0.0.7.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subpubpy-0.0.7-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file subpubpy-0.0.7.tar.gz.

File metadata

  • Download URL: subpubpy-0.0.7.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for subpubpy-0.0.7.tar.gz
Algorithm Hash digest
SHA256 7cd0714183eb7f8326e9dcccbc4dbc8120a4e276b26e1c45d2bfd3449c31b5cb
MD5 86a958e9c5c1c5281f8567b29aa34b5f
BLAKE2b-256 4c0b83e0cbb20a2524ef1db04be3c6a9ab8b15cac90244ed36ff872d5310d658

See more details on using hashes here.

File details

Details for the file subpubpy-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: subpubpy-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for subpubpy-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 eaec503270c53d1fc99b343a5105585aa89aa86388dfa65fef72bb2ed49d45b0
MD5 ec41c7329e7cfea2271c91b8b8fd3983
BLAKE2b-256 2ee39681d3897b6ab4f5b1e56aee7edc4d58865e81c26f67f0ffd2e84042a96d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page