# 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.
```python
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.
```python
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.
```python
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](https://github.com/Rahul-singh98/subpubpy/issues)***
Raw data
{
"_id": null,
"home_page": "https://codeart7.com",
"name": "subpubpy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8, <4",
"maintainer_email": "",
"keywords": "subpubpy,setuptools,development",
"author": "Rahul Singh",
"author_email": "rajput.rahul8510@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/4c/0b/83e0cbb20a2524ef1db04be3c6a9ab8b15cac90244ed36ff872d5310d658/subpubpy-0.0.7.tar.gz",
"platform": null,
"description": "# Subpubpy\n\n## Motivation\nAt the time of creating high level application, programmers usually shares data between the instances.\nSometimes 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.\n\n## Description\n\n* `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.\n\n```python\ndef pub(self, event: str, payload: Any, verbose: bool = True) -> None:\n \"\"\"Publishes the events.\n\n Parameters:\n -----------\n event: str\n event which need to be published.\n\n payload: Any\n Any kind of data structure to handle with event.\n\n verbose: Optional[bool]\n used for logging purpose if False no log message are passed.\n \"\"\"\n```\n`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.\n\n* `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. \n\n```python\ndef sub(self, event: str, callback: Callable[[str, Any], None], verbose: bool = True) -> Union[\n None, TypeError]:\n \"\"\"Subscribes event with callback.\\n\n Here it checks if callback is not callable then raises TypeError \\n\n else returns None.\n\n Parameters:\n -----------\n event: str\n event which need to be subscribe.\n\n callback: Callable\n callback must be callable function.\n\n verbose: Optional[bool]\n used for logging purpose if False no log message are passed.\n \"\"\"\n```\n`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.\n\n\n* `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. \n\n```python\ndef unsub(self, event: str, handler: Any, verbose: bool = True) -> Union[None, ValueError]:\n \"\"\"Unsubscribes event with callback.\\n\n Unsubscribe checks callback is assigned to event else raise ValueError.\n\n Parameters:\n -----------\n event: str\n event which need to be subscribe.\n\n hanlder: Any\n remove handler from the system.\n\n verbose: Optional[bool]\n used for logging purpose if False no log message are passed.\n \"\"\"\n```\n`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.\n\n\n## API\n\n### *SimpleSubpub*:\nSimple publish subscriber model which works under the main thread.\n\n### *ThreadSafeSubpub*:\nThread safe publish subscriber model which works under multithreading concept.\n\n### *RegexSubpub*:\nPublish subscriber model which works under the main thread with regular expressions.\n\n### *ThreadSafeRegexSubpub*:\nThread safe publish subscriber model which works under multithreading concept and regular expression.\n\n\n***If you find any issue please feel free to report that issue on [github](https://github.com/Rahul-singh98/subpubpy/issues)***\n",
"bugtrack_url": null,
"license": "",
"summary": "Multithreading supported python package for publisher and subscriber model.",
"version": "0.0.7",
"split_keywords": [
"subpubpy",
"setuptools",
"development"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2ee39681d3897b6ab4f5b1e56aee7edc4d58865e81c26f67f0ffd2e84042a96d",
"md5": "ec41c7329e7cfea2271c91b8b8fd3983",
"sha256": "eaec503270c53d1fc99b343a5105585aa89aa86388dfa65fef72bb2ed49d45b0"
},
"downloads": -1,
"filename": "subpubpy-0.0.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ec41c7329e7cfea2271c91b8b8fd3983",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8, <4",
"size": 6406,
"upload_time": "2023-01-17T09:19:22",
"upload_time_iso_8601": "2023-01-17T09:19:22.232719Z",
"url": "https://files.pythonhosted.org/packages/2e/e3/9681d3897b6ab4f5b1e56aee7edc4d58865e81c26f67f0ffd2e84042a96d/subpubpy-0.0.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4c0b83e0cbb20a2524ef1db04be3c6a9ab8b15cac90244ed36ff872d5310d658",
"md5": "86a958e9c5c1c5281f8567b29aa34b5f",
"sha256": "7cd0714183eb7f8326e9dcccbc4dbc8120a4e276b26e1c45d2bfd3449c31b5cb"
},
"downloads": -1,
"filename": "subpubpy-0.0.7.tar.gz",
"has_sig": false,
"md5_digest": "86a958e9c5c1c5281f8567b29aa34b5f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8, <4",
"size": 6135,
"upload_time": "2023-01-17T09:19:23",
"upload_time_iso_8601": "2023-01-17T09:19:23.871386Z",
"url": "https://files.pythonhosted.org/packages/4c/0b/83e0cbb20a2524ef1db04be3c6a9ab8b15cac90244ed36ff872d5310d658/subpubpy-0.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-17 09:19:23",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "subpubpy"
}