asyncwica


Nameasyncwica JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://git.psi.ch/proscan_data/py-wica/-/tree/async
SummaryA simple async python API to access wica-http SSE.
upload_time2022-12-22 14:32:02
maintainer
docs_urlNone
authorNiklas Laufkoetter
requires_python>=3.8,<4.0
licenseGPL v3
keywords wica-http wica async sse psi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyWica - Async Wica Python API
[![pipeline status](https://git.psi.ch/proscan_data/py-wica/badges/async/pipeline.svg)](https://git.psi.ch/proscan_data/py-wica/-/commits/async)
[![coverage report](https://git.psi.ch/proscan_data/py-wica/badges/async/coverage.svg)](https://git.psi.ch/proscan_data/py-wica/-/commits/async)

#### Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Quick-start Guid](#quick-start-guide)
- [Documentation](#documentation)
- [Dependencies](#dependencies)
- [Contribute](#contribute)
- [Project Changes and Tagged Releases](#project-changes-and-tagged-releases)
- [Developer Notes](#developer-notes)
- [Contact](#contact)

# Introduction
This project/package aims to provide a simple python interface to the wica-http server.
Check out the main branch to get the blocking version of the package

# Installation
Install with pip
```bash
pip install asyncwica
```
# Quick-start Guide
Here are some simple examples to get you started:
```python
import asyncio
import time


async def simple_example():
    """A simple example of how to use AsyncWicaStream. Run it in main by uncommenting it! """

    wica_stream = WicaStream(base_url="http://student08/ca/streams", channels=["MMAC3:STR:2"])

    async def run_stream():
        await wica_stream.create()
        async for message in wica_stream.subscribe():
            print(message)

    async def stop_stream():
        await asyncio.sleep(10)
        print(await wica_stream.destroy())

    await asyncio.gather(run_stream(), stop_stream())

async def example_using_with():
    """ An example using the compound statement async with and another method to exit the event loop. Run it in main by uncommenting it!"""
    async with WicaStream(base_url="http://student08/ca/streams", channels=["MMAC3:STR:2"]) as stream:
        i:int = 0
        async for message in stream.subscribe():
            i+=1
            print(message)
            if i == 25:
                break

async def multistream_example():
    """ An example of how to run multiple streams at once using aiostream. Run it in main by uncommenting it! """
    from aiostream import stream
    streams = []
    async def run_streams():
        for _ in range(10):
            wica_stream = WicaStream(base_url="http://student08/ca/streams", channels=["MMAC3:STR:2"])
            streams.append(wica_stream)
            await wica_stream.create()

        print("Doing someting else before starting the stream...")
        await asyncio.sleep(5)

        subscribed_streams = []

        for wica_stream in streams:
            print(f"Subscribing to stream {wica_stream.id}")
            subscribed_streams.append(wica_stream.subscribe())


        combine = stream.merge(*subscribed_streams)
        async with combine.stream() as streamer:
            async for item in streamer:
                print(item)
                continue


    async def stop_streams():
        await asyncio.sleep(25)
        for wica_stream in streams:
            print(await wica_stream.destroy())


    await asyncio.gather(run_streams(), stop_streams())


async def main():
    #await simple_example()
    #await example_using_with()
    #await multistream_example()
    pass

if __name__ == "__main__":
    asyncio.run(main())

```

# Documentation
Current Features:
* Custom Client to handle be able to extract last line of SSE with timestamp and message type.
* Simple functions to create, delete and subscribe to streams
* Fully Async (blocking versions available in main branch)

Check out the wiki for more info!

# Dependencies
* [httpx](https://github.com/encode/httpx/)

# Contribute
To contribute, simply clone the project.
You can uses ``` pip -r requirements.txt ``` or the make file to set up the project.


# Project Changes and Tagged Releases
* See the Changelog file for further information
* Project releases are available in pypi

# Developer Notes
Currently None

# Contact
If you have any questions pleas contract 'niklas.laufkoetter@psi.ch'

            

Raw data

            {
    "_id": null,
    "home_page": "https://git.psi.ch/proscan_data/py-wica/-/tree/async",
    "name": "asyncwica",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "wica-http,wica,async,SSE,PSI",
    "author": "Niklas Laufkoetter",
    "author_email": "niklas.laufkoetter@psi.ch",
    "download_url": "https://files.pythonhosted.org/packages/77/e9/9f86b77f8e3013d1bb01fb8252bcc7ce6bc4e4ebf96c0bc8a7faf76901bc/asyncwica-1.3.0.tar.gz",
    "platform": null,
    "description": "# PyWica - Async Wica Python API\n[![pipeline status](https://git.psi.ch/proscan_data/py-wica/badges/async/pipeline.svg)](https://git.psi.ch/proscan_data/py-wica/-/commits/async)\n[![coverage report](https://git.psi.ch/proscan_data/py-wica/badges/async/coverage.svg)](https://git.psi.ch/proscan_data/py-wica/-/commits/async)\n\n#### Table of Contents\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Quick-start Guid](#quick-start-guide)\n- [Documentation](#documentation)\n- [Dependencies](#dependencies)\n- [Contribute](#contribute)\n- [Project Changes and Tagged Releases](#project-changes-and-tagged-releases)\n- [Developer Notes](#developer-notes)\n- [Contact](#contact)\n\n# Introduction\nThis project/package aims to provide a simple python interface to the wica-http server.\nCheck out the main branch to get the blocking version of the package\n\n# Installation\nInstall with pip\n```bash\npip install asyncwica\n```\n# Quick-start Guide\nHere are some simple examples to get you started:\n```python\nimport asyncio\nimport time\n\n\nasync def simple_example():\n    \"\"\"A simple example of how to use AsyncWicaStream. Run it in main by uncommenting it! \"\"\"\n\n    wica_stream = WicaStream(base_url=\"http://student08/ca/streams\", channels=[\"MMAC3:STR:2\"])\n\n    async def run_stream():\n        await wica_stream.create()\n        async for message in wica_stream.subscribe():\n            print(message)\n\n    async def stop_stream():\n        await asyncio.sleep(10)\n        print(await wica_stream.destroy())\n\n    await asyncio.gather(run_stream(), stop_stream())\n\nasync def example_using_with():\n    \"\"\" An example using the compound statement async with and another method to exit the event loop. Run it in main by uncommenting it!\"\"\"\n    async with WicaStream(base_url=\"http://student08/ca/streams\", channels=[\"MMAC3:STR:2\"]) as stream:\n        i:int = 0\n        async for message in stream.subscribe():\n            i+=1\n            print(message)\n            if i == 25:\n                break\n\nasync def multistream_example():\n    \"\"\" An example of how to run multiple streams at once using aiostream. Run it in main by uncommenting it! \"\"\"\n    from aiostream import stream\n    streams = []\n    async def run_streams():\n        for _ in range(10):\n            wica_stream = WicaStream(base_url=\"http://student08/ca/streams\", channels=[\"MMAC3:STR:2\"])\n            streams.append(wica_stream)\n            await wica_stream.create()\n\n        print(\"Doing someting else before starting the stream...\")\n        await asyncio.sleep(5)\n\n        subscribed_streams = []\n\n        for wica_stream in streams:\n            print(f\"Subscribing to stream {wica_stream.id}\")\n            subscribed_streams.append(wica_stream.subscribe())\n\n\n        combine = stream.merge(*subscribed_streams)\n        async with combine.stream() as streamer:\n            async for item in streamer:\n                print(item)\n                continue\n\n\n    async def stop_streams():\n        await asyncio.sleep(25)\n        for wica_stream in streams:\n            print(await wica_stream.destroy())\n\n\n    await asyncio.gather(run_streams(), stop_streams())\n\n\nasync def main():\n    #await simple_example()\n    #await example_using_with()\n    #await multistream_example()\n    pass\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\n```\n\n# Documentation\nCurrent Features:\n* Custom Client to handle be able to extract last line of SSE with timestamp and message type.\n* Simple functions to create, delete and subscribe to streams\n* Fully Async (blocking versions available in main branch)\n\nCheck out the wiki for more info!\n\n# Dependencies\n* [httpx](https://github.com/encode/httpx/)\n\n# Contribute\nTo contribute, simply clone the project.\nYou can uses ``` pip -r requirements.txt ``` or the make file to set up the project.\n\n\n# Project Changes and Tagged Releases\n* See the Changelog file for further information\n* Project releases are available in pypi\n\n# Developer Notes\nCurrently None\n\n# Contact\nIf you have any questions pleas contract 'niklas.laufkoetter@psi.ch'\n",
    "bugtrack_url": null,
    "license": "GPL v3",
    "summary": "A simple async python API to access wica-http SSE.",
    "version": "1.3.0",
    "split_keywords": [
        "wica-http",
        "wica",
        "async",
        "sse",
        "psi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "734c4cfc4882bc5529f4c8f28ac2ceeb",
                "sha256": "61ec416edd8ca92a5641e470487eb24440c0f810bc00ffecd7089eda17527204"
            },
            "downloads": -1,
            "filename": "asyncwica-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "734c4cfc4882bc5529f4c8f28ac2ceeb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 33068,
            "upload_time": "2022-12-22T14:32:01",
            "upload_time_iso_8601": "2022-12-22T14:32:01.006858Z",
            "url": "https://files.pythonhosted.org/packages/4d/ad/11701c28e94fb42f9d78fa820af1f461b65cf5ca12d7bad129faeae2700e/asyncwica-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "eb80c50f864d3a8ff45d7a3699e5a7cd",
                "sha256": "120b5cd7ee458ffa007081b5b38bdadbe8e6af7dcf91f57b81d0216c9fb8b046"
            },
            "downloads": -1,
            "filename": "asyncwica-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "eb80c50f864d3a8ff45d7a3699e5a7cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 21066,
            "upload_time": "2022-12-22T14:32:02",
            "upload_time_iso_8601": "2022-12-22T14:32:02.732324Z",
            "url": "https://files.pythonhosted.org/packages/77/e9/9f86b77f8e3013d1bb01fb8252bcc7ce6bc4e4ebf96c0bc8a7faf76901bc/asyncwica-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-22 14:32:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "asyncwica"
}
        
Elapsed time: 0.25418s