cs.packetstream


Namecs.packetstream JSON
Version 20240412 PyPI version JSON
download
home_pageNone
Summarygeneral purpose bidirectional packet stream connection
upload_time2024-04-12 05:17:54
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseGNU General Public License v3 or later (GPLv3+)
keywords python2 python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            A general purpose bidirectional packet stream connection.

*Latest release 20240412*:
* PacketConnection: now subclasses MultiOpenMixin, big refactor.
* PacketConnection.__init__: use @promote to turn the recv parameter into a CornuCopyBuffer.
* Fix a deadlock.

## Class `Packet(cs.binary.SimpleBinary)`

A protocol packet.

*Method `Packet.__str__(self)`*:
pylint: disable=signature-differs

*Method `Packet.parse(bfr)`*:
Parse a `Packet` from a buffer.

*Method `Packet.transcribe(self)`*:
Transcribe this packet.

## Class `PacketConnection(cs.resources.MultiOpenMixin)`

A bidirectional binary connection for exchanging requests and responses.

*Method `PacketConnection.__init__(self, recv: cs.buffer.CornuCopyBuffer, send, request_handler=None, name=None, packet_grace=None, tick=None, recv_len_func=None, send_len_func=None)`*:
Initialise the PacketConnection.

Parameters:
* `recv`: inbound binary stream.
  This value is automatically promoted to a `cs.buffer.CornuCopyBuffer`
  by the `CornuCopyBuffer.promote` method.
* `recv_len_func`: optional function to compute the data
  length of a received packet; the default watches the offset
  on the receive stream
* `send`: outbound binary stream.
  If this is an `int` it is taken to be an OS file descriptor,
  otherwise it should be a binary file like object with `.write(bytes)`
  and `.flush()` methods.
  This objects _is not closed_ by the `PacketConnection`;
  the caller has responsibility for that.
* `send_len_func`: optional function to compute the data
  length of a sent packet; the default watches the offset
  on the send stream
* `packet_grace`:
  default pause in the packet sending worker
  to allow another packet to be queued
  before flushing the output stream.
  Default: `DEFAULT_PACKET_GRACE`s.
  A value of `0` will flush immediately if the queue is empty.
* `request_handler`: an optional callable accepting
  (`rq_type`, `flags`, `payload`).
  The request_handler may return one of 5 values on success:
  * `None`: response will be 0 flags and an empty payload.
  * `int`: flags only. Response will be the flags and an empty payload.
  * `bytes`: payload only. Response will be 0 flags and the payload.
  * `str`: payload only. Response will be 0 flags and the str
          encoded as bytes using UTF-8.
  * `(int, bytes)`: Specify flags and payload for response.
  An unsuccessful request should raise an exception, which
  will cause a failure response packet.
* `tick`: optional tick parameter, default `None`.
  If `None`, do nothing.
  If a Boolean, call `tick_fd_2` if true, otherwise do nothing.
  Otherwise `tick` should be a callable accepting a byteslike value.

*Method `PacketConnection.do(self, *a, **kw)`*:
Wrapper function to check that this instance is not closed.

*Method `PacketConnection.join(self)`*:
Wait for the receive side of the connection to terminate.

*Method `PacketConnection.request(self, *a, **kw)`*:
Wrapper function to check that this instance is not closed.

## Class `Request_State(builtins.tuple)`

RequestState(decode_response, result)

*Property `Request_State.decode_response`*:
Alias for field number 0

*Property `Request_State.result`*:
Alias for field number 1

## Function `tick_fd_2(bs)`

A low level tick function to write a short binary tick
to the standard error file descriptor.

This may be called by the send and receive workers to give
an indication of activity type.

# Release Log



*Release 20240412*:
* PacketConnection: now subclasses MultiOpenMixin, big refactor.
* PacketConnection.__init__: use @promote to turn the recv parameter into a CornuCopyBuffer.
* Fix a deadlock.

*Release 20211208*:
* Packet.__eq__: only test .rq_type if .is_request.
* Update tests for changes.

*Release 20210306*:
* Port to new cs.binary.Binary* classes.
* Some refactors and small fixes.

*Release 20191004*:
* PacketConnection: new optional parameter `packet_grace` to tune the send delay for additional packets before a flush, default DEFAULT_PACKET_GRACE (0.01s), 0 for no delay.
* Add a crude packet level activity ticker.

*Release 20190221*:
DISTINFO requirement updates.

*Release 20181228*:
Initial PyPI release.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cs.packetstream",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python2, python3",
    "author": null,
    "author_email": "Cameron Simpson <cs@cskk.id.au>",
    "download_url": "https://files.pythonhosted.org/packages/c6/07/ce8dbb323b170305677439e59879ea83b18cce090ff62d4ea579f37b0bd8/cs.packetstream-20240412.tar.gz",
    "platform": null,
    "description": "A general purpose bidirectional packet stream connection.\n\n*Latest release 20240412*:\n* PacketConnection: now subclasses MultiOpenMixin, big refactor.\n* PacketConnection.__init__: use @promote to turn the recv parameter into a CornuCopyBuffer.\n* Fix a deadlock.\n\n## Class `Packet(cs.binary.SimpleBinary)`\n\nA protocol packet.\n\n*Method `Packet.__str__(self)`*:\npylint: disable=signature-differs\n\n*Method `Packet.parse(bfr)`*:\nParse a `Packet` from a buffer.\n\n*Method `Packet.transcribe(self)`*:\nTranscribe this packet.\n\n## Class `PacketConnection(cs.resources.MultiOpenMixin)`\n\nA bidirectional binary connection for exchanging requests and responses.\n\n*Method `PacketConnection.__init__(self, recv: cs.buffer.CornuCopyBuffer, send, request_handler=None, name=None, packet_grace=None, tick=None, recv_len_func=None, send_len_func=None)`*:\nInitialise the PacketConnection.\n\nParameters:\n* `recv`: inbound binary stream.\n  This value is automatically promoted to a `cs.buffer.CornuCopyBuffer`\n  by the `CornuCopyBuffer.promote` method.\n* `recv_len_func`: optional function to compute the data\n  length of a received packet; the default watches the offset\n  on the receive stream\n* `send`: outbound binary stream.\n  If this is an `int` it is taken to be an OS file descriptor,\n  otherwise it should be a binary file like object with `.write(bytes)`\n  and `.flush()` methods.\n  This objects _is not closed_ by the `PacketConnection`;\n  the caller has responsibility for that.\n* `send_len_func`: optional function to compute the data\n  length of a sent packet; the default watches the offset\n  on the send stream\n* `packet_grace`:\n  default pause in the packet sending worker\n  to allow another packet to be queued\n  before flushing the output stream.\n  Default: `DEFAULT_PACKET_GRACE`s.\n  A value of `0` will flush immediately if the queue is empty.\n* `request_handler`: an optional callable accepting\n  (`rq_type`, `flags`, `payload`).\n  The request_handler may return one of 5 values on success:\n  * `None`: response will be 0 flags and an empty payload.\n  * `int`: flags only. Response will be the flags and an empty payload.\n  * `bytes`: payload only. Response will be 0 flags and the payload.\n  * `str`: payload only. Response will be 0 flags and the str\n          encoded as bytes using UTF-8.\n  * `(int, bytes)`: Specify flags and payload for response.\n  An unsuccessful request should raise an exception, which\n  will cause a failure response packet.\n* `tick`: optional tick parameter, default `None`.\n  If `None`, do nothing.\n  If a Boolean, call `tick_fd_2` if true, otherwise do nothing.\n  Otherwise `tick` should be a callable accepting a byteslike value.\n\n*Method `PacketConnection.do(self, *a, **kw)`*:\nWrapper function to check that this instance is not closed.\n\n*Method `PacketConnection.join(self)`*:\nWait for the receive side of the connection to terminate.\n\n*Method `PacketConnection.request(self, *a, **kw)`*:\nWrapper function to check that this instance is not closed.\n\n## Class `Request_State(builtins.tuple)`\n\nRequestState(decode_response, result)\n\n*Property `Request_State.decode_response`*:\nAlias for field number 0\n\n*Property `Request_State.result`*:\nAlias for field number 1\n\n## Function `tick_fd_2(bs)`\n\nA low level tick function to write a short binary tick\nto the standard error file descriptor.\n\nThis may be called by the send and receive workers to give\nan indication of activity type.\n\n# Release Log\n\n\n\n*Release 20240412*:\n* PacketConnection: now subclasses MultiOpenMixin, big refactor.\n* PacketConnection.__init__: use @promote to turn the recv parameter into a CornuCopyBuffer.\n* Fix a deadlock.\n\n*Release 20211208*:\n* Packet.__eq__: only test .rq_type if .is_request.\n* Update tests for changes.\n\n*Release 20210306*:\n* Port to new cs.binary.Binary* classes.\n* Some refactors and small fixes.\n\n*Release 20191004*:\n* PacketConnection: new optional parameter `packet_grace` to tune the send delay for additional packets before a flush, default DEFAULT_PACKET_GRACE (0.01s), 0 for no delay.\n* Add a crude packet level activity ticker.\n\n*Release 20190221*:\nDISTINFO requirement updates.\n\n*Release 20181228*:\nInitial PyPI release.\n\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 or later (GPLv3+)",
    "summary": "general purpose bidirectional packet stream connection",
    "version": "20240412",
    "project_urls": {
        "URL": "https://bitbucket.org/cameron_simpson/css/commits/all"
    },
    "split_keywords": [
        "python2",
        " python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0b5214f4fad43f751ff87cc76f04fc452bb7ed465aaeb193263971a1b2f8f8f",
                "md5": "a3eca65adaa032a3a33a2991d707dcfa",
                "sha256": "38687c04386adff75aa3a49a15be0ada255737715a059586e71fdee2e5b6e1db"
            },
            "downloads": -1,
            "filename": "cs.packetstream-20240412-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3eca65adaa032a3a33a2991d707dcfa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10129,
            "upload_time": "2024-04-12T05:17:52",
            "upload_time_iso_8601": "2024-04-12T05:17:52.527473Z",
            "url": "https://files.pythonhosted.org/packages/b0/b5/214f4fad43f751ff87cc76f04fc452bb7ed465aaeb193263971a1b2f8f8f/cs.packetstream-20240412-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c607ce8dbb323b170305677439e59879ea83b18cce090ff62d4ea579f37b0bd8",
                "md5": "7a9424d2254a18a522979204e25051a7",
                "sha256": "f6fbfb389b01c5cd9505aedd4a1d352c5f8d8bab09132ad4cb4948104e1f0a81"
            },
            "downloads": -1,
            "filename": "cs.packetstream-20240412.tar.gz",
            "has_sig": false,
            "md5_digest": "7a9424d2254a18a522979204e25051a7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10567,
            "upload_time": "2024-04-12T05:17:54",
            "upload_time_iso_8601": "2024-04-12T05:17:54.155049Z",
            "url": "https://files.pythonhosted.org/packages/c6/07/ce8dbb323b170305677439e59879ea83b18cce090ff62d4ea579f37b0bd8/cs.packetstream-20240412.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 05:17:54",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "cameron_simpson",
    "bitbucket_project": "css",
    "lcname": "cs.packetstream"
}
        
Elapsed time: 0.23105s