Metadata-Version: 2.1
Name: eisenmp
Version: 1.0
Summary: Multiprocess Framework for Server and Mobiles; run your generator output and server on every CPU core,
Author: René Horn
Author-email: René Horn <rene_horn@gmx.net>
License: BSD 3-Clause License
        
        Copyright (c) 2023, René Horn
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: homepage, https://github.com/44xtc44
Project-URL: documentation, https://eisenmp.readthedocs.io/
Project-URL: repository, https://github.com/44xtc44/eisenmp
Keywords: multiprocess framework,python multiprocessor framework
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
Provides-Extra: testing
License-File: LICENSE
License-File: LICENSE.rst

Introduction
############

.. image:: https://github.com/44xtc44/eisenmp/actions/workflows/tests.yml/badge.svg
   :target: https://github.com/44xtc44/eisenmp/actions/workflows/tests.yml


Python 3.7

`Multiprocessor <https://en.wikipedia.org/wiki/Multiprocessing>`_
`Framework <https://en.wikipedia.org/wiki/Software_framework>`_ for single Server

Kwargs To Go

Features:

* **Uniform** foundation to create multiprocess project modules
* **Workload Chunks** with header to control output and speed up a specific task
* Chunks get a serial number (ID), findings can be checked in a result dictionary, which ID is missing
* **module_loader** decouples your Worker imports from Main()
* **Categories of Queues**, assign Names to Queues and groups of Queues
* **Queue list** helps to debug your setup and reveals the name, object id and object reference of every Queue
* **Print Queue** allows formatted print to screen for your processes (blocks)
* No libraries, (Linux, Windows)

| Visit the features above in the `Examples gitHub repository <https://github.com/44xtc44/eisenmp_examples>`_
| or

download the all inclusive `PyPi Examples package <https://pypi.org/project/eisenmp-examples/>`_ and
execute **eisenmp_url** in Terminal to start the simpleHTTP Ajax server

| All scenarios run on **Template Style Modules**. Enjoy the descriptions.

How it works
~~~~~~~~~~~~
You write two functions and two modules.
Let's name them **Manager.py** and **Worker.py**.

1. Manager.py defines custom objects and starts a new process, target is **module_loader.py** (loader)
2. loader imports your (independent) Worker.py module from file system without side effects
3. loader sits in a loop and calls your Worker.py entry function until queue is empty
4. **q_feeder** iterator sends a STOP message. Your Worker reads STOP, return False and exit.
5. **module_loader** module then puts a STOP Worker message in all other input queues.
6. **Next** Worker reads STOP, exit ...
7. Loader runs idle and awaits the internal STOP Process message.

.. image:: ./docs/source/_static/eisenmp_pic_loader.svg
  :width: 640
  :alt: Worker module loader, loads independent, no imports of parent

Generators
~~~~~~~~~~~

.. image:: ./docs/source/_static/eisenmp_pic_generator.svg
  :width: 640
  :alt: Generator, iterator, lists with name and ID header

Variables transfer to worker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The worker should be more flexible. Thus, it needs more structured information.

* Information collector is the ``ModuleConfiguration`` class instance. The class can carry any name.
* All instance attributes are stored in a dictionary __dict__. (self.foo will be kwargs.foo)
* The instance dictionary is argument (`kwargs`) to call the eisenmp start method.
* `Kwargs` is updated further with queue information and the START_SEQUENCE_NUM of the process, before process start.

.. image:: ./docs/source/_static/eisenmp_pic_kwargs.svg
  :width: 640
  :alt: Generator, Iterator makes lists, result in dictionary


Default Queues

- ``Input`` worker lists, ``Output`` result and stop lists
- ``Tools``, ``Print``, ``Info``

How to run the examples?
~~~~~~~~~~~~~~~~~~~~~~~~~
Fast `PyPi package <https://pypi.org/project/eisenmp-examples/>`_. **eisenmp** will be installed also.

In depth. Clone both repos.

`eisenmp <https://github.com/44xtc44/eisenmp>`_ and
`eisenmp_examples <https://github.com/44xtc44/eisenmp_examples>`_

Install in editable pip mode.

::

    cd eisenmp
    pip3 install -e .  # uninstall (linux pip3) with: pip3 uninstall eisenmp

    cd eisenmp_examples
    pip3 install -e .  # uninstall with: pip3 uninstall eisenmp_examples

Run the examples. Either local Ajax Web server or terminal menu.

::

    eisenmp_url
    # or
    eisenmp_menu

Get the documentation on readthedocs https://eisenmp.readthedocs.io/

