concurrently


Nameconcurrently JSON
Version 2.1 PyPI version JSON
download
home_pagehttps://github.com/sirkonst/concurrently
SummaryLibrary helps easy write concurrent executed code blocks
upload_time2025-01-19 11:19:42
maintainerKonstantin Enchant
docs_urlNone
authorKonstantin Enchant
requires_python>=3.5
licenseNone
keywords concurrent thread threading process multiprocessing asyncio gevent
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Concurrently
============

Library helps to easily write concurrent executed code blocks.

Quick example:

.. code-block:: python

    import asyncio
    from concurrently import concurrently


    async def amain(loop):
        """
        How to fetch some web pages with concurrently.
        """
        urls = [  # define pages urls
            'http://test/page_1',
            'http://test/page_2',
            'http://test/page_3',
            'http://test/page_4',
        ]
        results = {}

        # immediately run wrapped function concurrent
        # in 2 thread (asyncio coroutines)
        @concurrently(2)
        async def fetch_urls():
            for url in urls:
                # some function for download page
                page = await fetch_page(url)
                results[url] = page

        # wait until all concurrent threads finished
        await fetch_urls()
        print(results)


    if __name__ == '__main__':
        loop = asyncio.get_event_loop()
        loop.run_until_complete(amain(loop))


Decorator `@concurrently` makes to main thinks:
    * starts concurrent execution specified count of decorated function
    * returns special `waiter` object to control the running functions

By default, the code runs as asyncio coroutines, but there are other supported
ways to execute, by specifying the argument `engine`.


Documentation
-------------

See https://concurrently.readthedocs.io/


Requirements
============

Now support only **Python 3.5** and above.


Install
=======

From PyPi:

.. code-block:: bash

    $ pip install concurrently


From local:

.. code-block:: bash

    # update setuptools
    $ pip install 'setuptools >= 30.4'
    # do install
    $ make install
    # or
    $ pip install .


Development
===========

Prepare and activate virtual environment like:

.. code-block:: bash

    $ python3 -m venv .env
    # for bash
    $ source .env/bin/activate
    # for fish
    $ . .env/bin/activate.fish

Update pre-install dependencies:

.. code-block:: bash

    $ pip install 'setuptools >= 30.4'

Install:

.. code-block:: bash

    $ make install_dev
    # or
    $ pip install --editable .[develop]

Run tests:

.. code-block:: bash

    $ make test
    # or
    $ pytest tests/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sirkonst/concurrently",
    "name": "concurrently",
    "maintainer": "Konstantin Enchant",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "sirkonst@gmail.com",
    "keywords": "concurrent, thread, threading, process, multiprocessing, asyncio, gevent",
    "author": "Konstantin Enchant",
    "author_email": "sirkonst@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d4/cb/528221dfd10c944ddc2531b6882ad13513a35670ed418a494fe328d1375b/concurrently-2.1.tar.gz",
    "platform": null,
    "description": "Concurrently\n============\n\nLibrary helps to easily write concurrent executed code blocks.\n\nQuick example:\n\n.. code-block:: python\n\n    import asyncio\n    from concurrently import concurrently\n\n\n    async def amain(loop):\n        \"\"\"\n        How to fetch some web pages with concurrently.\n        \"\"\"\n        urls = [  # define pages urls\n            'http://test/page_1',\n            'http://test/page_2',\n            'http://test/page_3',\n            'http://test/page_4',\n        ]\n        results = {}\n\n        # immediately run wrapped function concurrent\n        # in 2 thread (asyncio coroutines)\n        @concurrently(2)\n        async def fetch_urls():\n            for url in urls:\n                # some function for download page\n                page = await fetch_page(url)\n                results[url] = page\n\n        # wait until all concurrent threads finished\n        await fetch_urls()\n        print(results)\n\n\n    if __name__ == '__main__':\n        loop = asyncio.get_event_loop()\n        loop.run_until_complete(amain(loop))\n\n\nDecorator `@concurrently` makes to main thinks:\n    * starts concurrent execution specified count of decorated function\n    * returns special `waiter` object to control the running functions\n\nBy default, the code runs as asyncio coroutines, but there are other supported\nways to execute, by specifying the argument `engine`.\n\n\nDocumentation\n-------------\n\nSee https://concurrently.readthedocs.io/\n\n\nRequirements\n============\n\nNow support only **Python 3.5** and above.\n\n\nInstall\n=======\n\nFrom PyPi:\n\n.. code-block:: bash\n\n    $ pip install concurrently\n\n\nFrom local:\n\n.. code-block:: bash\n\n    # update setuptools\n    $ pip install 'setuptools >= 30.4'\n    # do install\n    $ make install\n    # or\n    $ pip install .\n\n\nDevelopment\n===========\n\nPrepare and activate virtual environment like:\n\n.. code-block:: bash\n\n    $ python3 -m venv .env\n    # for bash\n    $ source .env/bin/activate\n    # for fish\n    $ . .env/bin/activate.fish\n\nUpdate pre-install dependencies:\n\n.. code-block:: bash\n\n    $ pip install 'setuptools >= 30.4'\n\nInstall:\n\n.. code-block:: bash\n\n    $ make install_dev\n    # or\n    $ pip install --editable .[develop]\n\nRun tests:\n\n.. code-block:: bash\n\n    $ make test\n    # or\n    $ pytest tests/\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Library helps easy write concurrent executed code blocks",
    "version": "2.1",
    "project_urls": {
        "Homepage": "https://github.com/sirkonst/concurrently"
    },
    "split_keywords": [
        "concurrent",
        " thread",
        " threading",
        " process",
        " multiprocessing",
        " asyncio",
        " gevent"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f02e366c547b67bb44603377bbaabe92aab4e0ee2483c84b4ea475b97e996fe6",
                "md5": "2657e1cde21dea5426f7cd9c6c5ea181",
                "sha256": "d80305f488cf400c76c575eae78c0f99c8c67d4510181f903d15d3b2722019ad"
            },
            "downloads": -1,
            "filename": "concurrently-2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2657e1cde21dea5426f7cd9c6c5ea181",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 14926,
            "upload_time": "2025-01-19T11:19:40",
            "upload_time_iso_8601": "2025-01-19T11:19:40.259547Z",
            "url": "https://files.pythonhosted.org/packages/f0/2e/366c547b67bb44603377bbaabe92aab4e0ee2483c84b4ea475b97e996fe6/concurrently-2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d4cb528221dfd10c944ddc2531b6882ad13513a35670ed418a494fe328d1375b",
                "md5": "1ee6b003e70241c959ce5bc8a17182f6",
                "sha256": "f477dbee46bf2deb2a88e5ed846f0306ddad34b9cf7c3d78e69be97b73904ff1"
            },
            "downloads": -1,
            "filename": "concurrently-2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1ee6b003e70241c959ce5bc8a17182f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 10701,
            "upload_time": "2025-01-19T11:19:42",
            "upload_time_iso_8601": "2025-01-19T11:19:42.128628Z",
            "url": "https://files.pythonhosted.org/packages/d4/cb/528221dfd10c944ddc2531b6882ad13513a35670ed418a494fe328d1375b/concurrently-2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-19 11:19:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sirkonst",
    "github_project": "concurrently",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "tox": true,
    "lcname": "concurrently"
}
        
Elapsed time: 0.56734s