{ "info": { "author": "Evan Borgstrom", "author_email": "evan.borgstrom@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Offspring\n=========\n\n.. image:: https://img.shields.io/travis/borgstrom/offspring.svg\n :target: https://travis-ci.org/borgstrom/offspring\n\n.. image:: https://img.shields.io/codecov/c/github/borgstrom/offspring.svg\n :target: https://codecov.io/github/borgstrom/offspring\n\n.. image:: https://img.shields.io/pypi/v/offspring.svg\n :target: https://pypi.python.org/pypi/offspring\n :alt: Latest PyPI version\n\n\nThis is a collection of objects and patterns for working with processes in Python using the multiprocessing library.\n\nThe main idea is that you express your unit of work as a simple method on an object and then when that object is\ninstantiated the work will be run in a subprocess.\n\n\nUse cases\n---------\n\nOffspring was built to address the following use cases for running code in a subprocess.\n\n\nRun something once\n~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from offspring import Subprocess\n\n\n class MyTask(Subprocess):\n def init(self, arg1):\n # This is run in the parent process and is used to prepare your object.\n # It receives whatever arguments were supplied to the constructor.\n self.arg1 = arg1\n\n def run(self):\n # This will be run in the child process and completes your work.\n # ...\n\n\n MyTask('this is arg1').wait()\n\n\nRun in a loop\n~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from offspring import SubprocessLoop\n\n\n class MyTask(SubprocessLoop):\n def init(self, arg1):\n # This is the same as init for Subprocess.\n self.arg1 = arg1\n\n def begin(self):\n # Called before the start of the loop in your child process.\n # ...\n\n def loop(self):\n # Called each loop iteration in your your child process.\n # It can return a sleep duration until the next loop, or False to stop the loop.\n # ...\n\n def end(self):\n # Called after the end of the loop, before termination in your child process.\n # ...\n\n\n MyTask('this is arg1').wait()\n\n\nImplementation details\n----------------------\n\n``.init(*args, **kwargs)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nCalled when an instance of your class is created. It receives the same arguments as the ``__init__`` method, so you are\nencouraged to explicitly define the arguments you expect.\n\n\n``.start()``\n~~~~~~~~~~~~\n\nCreates the subprocess. This is automatically called unless you set ``EXPLICIT_START`` to ``True``.\n\n\n``.wait()``\n~~~~~~~~~~~\n\nIf you need to wait for your child process you can call ``.wait`` on your ``Subprocess`` object. This is just a\nshortcut to ``.join`` on the ``multiprocessing.Process`` object.\n\n\n``.shutdown()``\n~~~~~~~~~~~~~~~\n\nThis will send a ``TERM`` signal to the child process, unless ``TERMINATE_ON_SHUTDOWN`` is ``False``, and then calls\n``.wait()`` to join the child process. It is automatically called whenever the parent process exits via the ``atexit``\nmodule.\n\n\n``.process``\n~~~~~~~~~~~~\n\nEach ``Subprocess`` object has a ``.process`` attribute that is the ``multiprocessing.Process`` object.\n\n\n``WAIT_FOR_CHILD``\n~~~~~~~~~~~~~~~~~~\n\nDefaults to ``False``.\n\nIf set to ``True`` on your ``Subprocess`` class then a ``Pipe`` will be used to block the parent process until the child\nhas started. This is useful when you want to ensure that your ``Subprocess`` object is started and ``.run`` is called\neven if the parent process exits quickly.\n\n.. code-block:: python\n\n class MyTask(Subprocess):\n WAIT_FOR_CHILD = True\n\n def run(self):\n print(\"This will always print\")\n\n MyTask()\n\nThe ``SubprocessLoop`` class does this to ensure that your object has ``begin`` & ``end`` called (``loop`` may not be\ncalled as a TERM signal received during startup will prevent the loop from every actually completing other than\n``begin`` & ``end``).\n\n\n``TERMINATE_ON_SHUTDOWN``\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDefaults to ``True``.\n\nIf set to ``False`` then when ``.shutdown`` is called on a ``Subprocess`` object the child process **will not** be\nterminated before being joined. This means that the parent will block until the child completes the ``.run`` function.\n\n.. code-block:: python\n\n import time\n\n class MyTask(Subprocess):\n TERMINATE_ON_SHUTDOWN = False\n\n def run(self):\n time.sleep(2)\n\n MyTask()\n\n\n``EXPLICIT_START``\n~~~~~~~~~~~~~~~~~~\n\nDefaults to ``False``.\n\nIf set to ``True`` then when you instantiate an object you must explicitly call ``.start()`` before the child process\nwill be spawned.\n\n.. code-block:: python\n\n class MyTask(Subprocess):\n EXPLICIT_START = True\n\n def run(self):\n print(\"Running!\")\n\n\n task = MyTask()\n # Do some other work\n task.start()\n # Running! is now printed\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/borgstrom/offspring", "keywords": "", "license": "Apache 2", "maintainer": "", "maintainer_email": "", "name": "offspring", "package_url": "https://pypi.org/project/offspring/", "platform": "", "project_url": "https://pypi.org/project/offspring/", "project_urls": { "Homepage": "https://github.com/borgstrom/offspring" }, "release_url": "https://pypi.org/project/offspring/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Objects and patterns for working with processes in Python using the multiprocessing library", "version": "0.1.1" }, "last_serial": 3462534, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1ff29ceef1ea9659a9da10bb99b02354", "sha256": "a5665a067a94604c2d915ac6e2b6d1c271ee598d03fa50a8d33f509c7a65f24a" }, "downloads": -1, "filename": "offspring-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1ff29ceef1ea9659a9da10bb99b02354", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 3490, "upload_time": "2017-05-30T04:42:19", "url": "https://files.pythonhosted.org/packages/42/22/07ebb4ec824af4d5ea1f9482598ecd6f1776660bbc8412865d80a5313f0c/offspring-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "40c28c98e4f2b78c05c39e7a6e1826ff", "sha256": "cae39cf9a091701663032d6d4e5dc035026940a31143d85758625410cb88e658" }, "downloads": -1, "filename": "offspring-0.0.1.tar.gz", "has_sig": false, "md5_digest": "40c28c98e4f2b78c05c39e7a6e1826ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2270, "upload_time": "2017-05-30T04:42:17", "url": "https://files.pythonhosted.org/packages/40/71/06c1dcfd1bea767611b7167605ea8007aeb4990ea827c8845c7f2ea8eb60/offspring-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "14aa9678abbec4fb6c482b35883ebc99", "sha256": "b90f60a6aeb8981a4b59011a4a16f7e30d09abb5761253640b303d14826ddf6e" }, "downloads": -1, "filename": "offspring-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "14aa9678abbec4fb6c482b35883ebc99", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 5863, "upload_time": "2017-05-30T04:54:47", "url": "https://files.pythonhosted.org/packages/7c/0e/af77761737f686fb495fb2954d8b3b84cd00105b486ffcb90425cc1c2ac9/offspring-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c2f9ce737677bf7b124be99c8fc15b56", "sha256": "1ddc392e73cad663616e7b6bbfe52bf681e6702333050d6ba677c3fd6e594454" }, "downloads": -1, "filename": "offspring-0.0.2.tar.gz", "has_sig": false, "md5_digest": "c2f9ce737677bf7b124be99c8fc15b56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3715, "upload_time": "2017-05-30T04:54:45", "url": "https://files.pythonhosted.org/packages/16/fb/913535aedb1d84697d162c6b82d13c63629f9f5c49955491501137425878/offspring-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "9941b8567fba687bb5f9a72637538ee2", "sha256": "fdf65e47b36d874dd7364548a077b7f943ce6203d3699c8153c6b39223f77ab5" }, "downloads": -1, "filename": "offspring-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9941b8567fba687bb5f9a72637538ee2", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 6019, "upload_time": "2017-05-30T05:08:37", "url": "https://files.pythonhosted.org/packages/15/8e/8fd980a7744110d1971bd0ff3024292eca91408c8048905e2bc2d6d1b2d7/offspring-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "20d86bfc2be69bfb421accd8e2aa3a20", "sha256": "2c52646129e4750cfc9909de9b3545935995eff6a70bedac7e7cb89a81a6f89d" }, "downloads": -1, "filename": "offspring-0.0.3.tar.gz", "has_sig": false, "md5_digest": "20d86bfc2be69bfb421accd8e2aa3a20", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3852, "upload_time": "2017-05-30T05:08:36", "url": "https://files.pythonhosted.org/packages/9e/d7/043f4bc270ea0930c4ee69f3b63c88111b53af9492116fb77b87e3a8fd79/offspring-0.0.3.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2a30ed78a227031a1abadeed41454d5b", "sha256": "3fe701aa67a982e899cfefaecdbec29c2223fd93779aaa60e9dd3e74d24ac6d0" }, "downloads": -1, "filename": "offspring-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2a30ed78a227031a1abadeed41454d5b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6680, "upload_time": "2018-01-04T19:17:59", "url": "https://files.pythonhosted.org/packages/61/d3/cd60771acf94c9171521288005784812692a729cd76a82ddcf714e0fcbe8/offspring-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "236db3833cc7f1008732c36319e8862a", "sha256": "e30c37b5f98c5bc2e0889a0c24a3ced91fac10f3bff090873d3c14ea7acc0c53" }, "downloads": -1, "filename": "offspring-0.1.1.tar.gz", "has_sig": false, "md5_digest": "236db3833cc7f1008732c36319e8862a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4207, "upload_time": "2018-01-04T19:18:00", "url": "https://files.pythonhosted.org/packages/08/51/1e7130113a14882969b78081ee11bc159946b70fbb098bd839903239f613/offspring-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2a30ed78a227031a1abadeed41454d5b", "sha256": "3fe701aa67a982e899cfefaecdbec29c2223fd93779aaa60e9dd3e74d24ac6d0" }, "downloads": -1, "filename": "offspring-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2a30ed78a227031a1abadeed41454d5b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6680, "upload_time": "2018-01-04T19:17:59", "url": "https://files.pythonhosted.org/packages/61/d3/cd60771acf94c9171521288005784812692a729cd76a82ddcf714e0fcbe8/offspring-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "236db3833cc7f1008732c36319e8862a", "sha256": "e30c37b5f98c5bc2e0889a0c24a3ced91fac10f3bff090873d3c14ea7acc0c53" }, "downloads": -1, "filename": "offspring-0.1.1.tar.gz", "has_sig": false, "md5_digest": "236db3833cc7f1008732c36319e8862a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4207, "upload_time": "2018-01-04T19:18:00", "url": "https://files.pythonhosted.org/packages/08/51/1e7130113a14882969b78081ee11bc159946b70fbb098bd839903239f613/offspring-0.1.1.tar.gz" } ] }