sseclient


Namesseclient JSON
Version 0.0.27 PyPI version JSON
download
home_pagehttps://github.com/btubbs/sseclient
SummaryPython client library for reading Server Sent Event streams.
upload_time2020-09-25 02:46:41
maintainer
docs_urlNone
authorBrent Tubbs
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            =================
Python SSE Client
=================

This is a Python client library for iterating over http Server Sent Event (SSE)
streams (also known as EventSource, after the name of the Javascript interface
inside browsers).  The SSEClient class accepts a url on init, and is then an
iterator over messages coming from the server.

Installation
------------

Use pip::

    pip install sseclient

Usage
-----

::

    from sseclient import SSEClient

    messages = SSEClient('http://mysite.com/sse_stream/')
    for msg in messages:
        do_something_useful(msg)

Each message object will have a 'data' attribute, as well as optional 'event',
'id', and 'retry' attributes.

Optional init parameters:

- last_id: If provided, this parameter will be sent to the server to tell it to
  return only messages more recent than this ID.

- retry: Number of milliseconds to wait after disconnects before attempting to
  reconnect.  The server may change this by including a 'retry' line in a
  message.  Retries are handled automatically by the SSEClient object.

You may also provide any additional keyword arguments supported by the
Requests_ library, such as a 'headers' dict and a (username, password) tuple
for 'auth'.

Development
-----------

Install the library in editable mode::

    pip install -e .

Install the test dependencies::

    pip install pytest backports.unittest_mock

Run the tests with py.test::

    (sseclient)vagrant sseclient $ py.test
    ===================== test session starts ======================
    platform linux2 -- Python 2.7.6 -- py-1.4.30 -- pytest-2.7.2
    rootdir: /vagrant/code/sseclient, inifile: 
    plugins: backports.unittest-mock
    collected 11 items 

    test_sseclient.py ...........

    ================== 11 passed in 0.19 seconds ===================

There are a couple TODO items in the code for getting the implementation
completely in line with the finer points of the SSE spec.

Additional Resources
--------------------

- `HTML5Rocks Tutorial`_
- `Official SSE Spec`_

.. _Requests: https://requests.readthedocs.io/
.. _HTML5Rocks Tutorial: https://www.html5rocks.com/en/tutorials/eventsource/basics/
.. _Official SSE Spec: https://html.spec.whatwg.org/multipage/comms.html#server-sent-events
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/btubbs/sseclient",
    "name": "sseclient",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Brent Tubbs",
    "author_email": "brent.tubbs@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cf/6c/fa601216344952be8f9a51a3f49b4274bbbc58bd395f87f67f6131726358/sseclient-0.0.27.tar.gz",
    "platform": "",
    "description": "=================\nPython SSE Client\n=================\n\nThis is a Python client library for iterating over http Server Sent Event (SSE)\nstreams (also known as EventSource, after the name of the Javascript interface\ninside browsers).  The SSEClient class accepts a url on init, and is then an\niterator over messages coming from the server.\n\nInstallation\n------------\n\nUse pip::\n\n    pip install sseclient\n\nUsage\n-----\n\n::\n\n    from sseclient import SSEClient\n\n    messages = SSEClient('http://mysite.com/sse_stream/')\n    for msg in messages:\n        do_something_useful(msg)\n\nEach message object will have a 'data' attribute, as well as optional 'event',\n'id', and 'retry' attributes.\n\nOptional init parameters:\n\n- last_id: If provided, this parameter will be sent to the server to tell it to\n  return only messages more recent than this ID.\n\n- retry: Number of milliseconds to wait after disconnects before attempting to\n  reconnect.  The server may change this by including a 'retry' line in a\n  message.  Retries are handled automatically by the SSEClient object.\n\nYou may also provide any additional keyword arguments supported by the\nRequests_ library, such as a 'headers' dict and a (username, password) tuple\nfor 'auth'.\n\nDevelopment\n-----------\n\nInstall the library in editable mode::\n\n    pip install -e .\n\nInstall the test dependencies::\n\n    pip install pytest backports.unittest_mock\n\nRun the tests with py.test::\n\n    (sseclient)vagrant sseclient $ py.test\n    ===================== test session starts ======================\n    platform linux2 -- Python 2.7.6 -- py-1.4.30 -- pytest-2.7.2\n    rootdir: /vagrant/code/sseclient, inifile: \n    plugins: backports.unittest-mock\n    collected 11 items \n\n    test_sseclient.py ...........\n\n    ================== 11 passed in 0.19 seconds ===================\n\nThere are a couple TODO items in the code for getting the implementation\ncompletely in line with the finer points of the SSE spec.\n\nAdditional Resources\n--------------------\n\n- `HTML5Rocks Tutorial`_\n- `Official SSE Spec`_\n\n.. _Requests: https://requests.readthedocs.io/\n.. _HTML5Rocks Tutorial: https://www.html5rocks.com/en/tutorials/eventsource/basics/\n.. _Official SSE Spec: https://html.spec.whatwg.org/multipage/comms.html#server-sent-events",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python client library for reading Server Sent Event streams.",
    "version": "0.0.27",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "f512abac1dda6d096f7f62714e4b83ae",
                "sha256": "b2fe534dcb33b1d3faad13d60c5a7c718e28f85987f2a034ecf5ec279918c11c"
            },
            "downloads": -1,
            "filename": "sseclient-0.0.27.tar.gz",
            "has_sig": false,
            "md5_digest": "f512abac1dda6d096f7f62714e4b83ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7465,
            "upload_time": "2020-09-25T02:46:41",
            "upload_time_iso_8601": "2020-09-25T02:46:41.997253Z",
            "url": "https://files.pythonhosted.org/packages/cf/6c/fa601216344952be8f9a51a3f49b4274bbbc58bd395f87f67f6131726358/sseclient-0.0.27.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-09-25 02:46:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "btubbs",
    "github_project": "sseclient",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "sseclient"
}
        
Elapsed time: 0.05277s