stompman 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stompman-0.2.0 → stompman-0.2.1}/PKG-INFO +6 -1
- {stompman-0.2.0 → stompman-0.2.1}/pyproject.toml +8 -1
- {stompman-0.2.0 → stompman-0.2.1}/stompman/connection.py +5 -9
- {stompman-0.2.0 → stompman-0.2.1}/stompman/protocol.py +21 -36
- {stompman-0.2.0 → stompman-0.2.1}/LICENSE +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/README.md +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/stompman/__init__.py +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/stompman/client.py +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/stompman/errors.py +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/stompman/frames.py +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/stompman/listening_events.py +0 -0
- {stompman-0.2.0 → stompman-0.2.1}/stompman/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stompman
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Python STOMP client with pleasant API
|
|
5
5
|
Home-page: https://github.com/vrslev/stompman
|
|
6
6
|
License: MIT
|
|
@@ -8,10 +8,15 @@ Keywords: stomp,artemis,activemq,messaging,jms
|
|
|
8
8
|
Author: Lev Vereshchagin
|
|
9
9
|
Author-email: mail@vrslev.com
|
|
10
10
|
Requires-Python: >=3.11,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
12
14
|
Classifier: Programming Language :: Python :: 3
|
|
13
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: Topic :: System :: Networking
|
|
19
|
+
Classifier: Typing :: Typed
|
|
15
20
|
Project-URL: Repository, https://github.com/vrslev/stompman
|
|
16
21
|
Description-Content-Type: text/markdown
|
|
17
22
|
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "stompman"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "Python STOMP client with pleasant API"
|
|
5
5
|
license = "MIT"
|
|
6
6
|
authors = ["Lev Vereshchagin <mail@vrslev.com>"]
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
repository = "https://github.com/vrslev/stompman"
|
|
9
9
|
keywords = ["stomp", "artemis", "activemq", "messaging", "jms"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Natural Language :: English",
|
|
13
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
14
|
+
"Topic :: System :: Networking",
|
|
15
|
+
"Typing :: Typed",
|
|
16
|
+
]
|
|
10
17
|
|
|
11
18
|
[tool.poetry.dependencies]
|
|
12
19
|
python = "^3.11"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
from collections.abc import AsyncGenerator,
|
|
2
|
+
from collections.abc import AsyncGenerator, Iterator
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from typing import Protocol, TypeVar, cast
|
|
5
5
|
|
|
6
6
|
from stompman.errors import ConnectError, ReadTimeoutError
|
|
7
7
|
from stompman.frames import AnyRealFrame, ClientFrame, ServerFrame
|
|
8
|
-
from stompman.protocol import NEWLINE, Parser, dump_frame
|
|
8
|
+
from stompman.protocol import NEWLINE, Parser, dump_frame
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@dataclass
|
|
@@ -76,17 +76,13 @@ class Connection(AbstractConnection):
|
|
|
76
76
|
return chunk
|
|
77
77
|
|
|
78
78
|
async def read_frames(self) -> AsyncGenerator[ServerFrame, None]:
|
|
79
|
-
incomplete_bytes = b""
|
|
80
79
|
parser = Parser()
|
|
81
80
|
|
|
82
81
|
while True:
|
|
83
82
|
try:
|
|
84
|
-
|
|
83
|
+
raw_frames = await asyncio.wait_for(self._read_non_empty_bytes(), timeout=self.read_timeout)
|
|
85
84
|
except TimeoutError as exception:
|
|
86
|
-
raise ReadTimeoutError(
|
|
85
|
+
raise ReadTimeoutError(self.read_timeout) from exception
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
incomplete_bytes + received_bytes
|
|
90
|
-
)
|
|
91
|
-
for frame in cast(Iterable[ServerFrame], parser.load_frames(received_bytes)):
|
|
87
|
+
for frame in cast(Iterator[ServerFrame], parser.load_frames(raw_frames)):
|
|
92
88
|
yield frame
|
|
@@ -49,16 +49,6 @@ def dump_frame(frame: AnyRealFrame) -> bytes:
|
|
|
49
49
|
return b"".join(lines)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def separate_complete_and_incomplete_packet_parts(raw_frames: bytes) -> tuple[bytes, bytes]:
|
|
53
|
-
if raw_frames.replace(NEWLINE, b"") == b"":
|
|
54
|
-
return (raw_frames, b"")
|
|
55
|
-
parts = raw_frames.rpartition(NULL)
|
|
56
|
-
if parts[2].replace(NEWLINE, b"") == b"":
|
|
57
|
-
return (raw_frames, b"")
|
|
58
|
-
|
|
59
|
-
return parts[0] + parts[1], parts[2]
|
|
60
|
-
|
|
61
|
-
|
|
62
52
|
def unescape_byte(byte: bytes, previous_byte: bytes | None) -> bytes | None:
|
|
63
53
|
if byte == b"\\":
|
|
64
54
|
return None
|
|
@@ -106,43 +96,38 @@ def parse_lines_into_frame(lines: deque[list[bytes]]) -> AnyFrame | None:
|
|
|
106
96
|
|
|
107
97
|
@dataclass
|
|
108
98
|
class Parser:
|
|
109
|
-
|
|
99
|
+
_lines: deque[list[bytes]] = field(default_factory=deque, init=False)
|
|
100
|
+
_current_line: list[bytes] = field(default_factory=list, init=False)
|
|
101
|
+
_previous_byte: bytes = field(default=b"", init=False)
|
|
102
|
+
_headers_processed: bool = field(default=False, init=False)
|
|
110
103
|
|
|
111
104
|
def load_frames(self, raw_frames: bytes) -> Iterator[AnyFrame]:
|
|
112
|
-
|
|
113
|
-
buffer = deque(struct.unpack(f"{len(all_bytes)!s}c", all_bytes))
|
|
114
|
-
lines = deque[list[bytes]]()
|
|
115
|
-
current_line: list[bytes] = []
|
|
116
|
-
previous_byte = None
|
|
117
|
-
headers_processed = False
|
|
118
|
-
|
|
105
|
+
buffer = deque(struct.unpack(f"{len(raw_frames)!s}c", raw_frames))
|
|
119
106
|
while buffer:
|
|
120
107
|
byte = buffer.popleft()
|
|
121
108
|
|
|
122
|
-
if
|
|
123
|
-
|
|
124
|
-
if parsed_frame := parse_lines_into_frame(
|
|
109
|
+
if self._headers_processed and byte == NULL:
|
|
110
|
+
self._lines.append(self._current_line)
|
|
111
|
+
if parsed_frame := parse_lines_into_frame(self._lines):
|
|
125
112
|
yield parsed_frame
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
113
|
+
self._headers_processed = False
|
|
114
|
+
self._lines.clear()
|
|
115
|
+
self._current_line = []
|
|
129
116
|
|
|
130
|
-
elif not
|
|
131
|
-
if
|
|
132
|
-
if not
|
|
133
|
-
|
|
117
|
+
elif not self._headers_processed and byte == NEWLINE:
|
|
118
|
+
if self._current_line or self._lines:
|
|
119
|
+
if not self._current_line: # extra empty line after headers
|
|
120
|
+
self._headers_processed = True
|
|
134
121
|
|
|
135
|
-
if
|
|
136
|
-
|
|
122
|
+
if self._previous_byte == b"\r":
|
|
123
|
+
self._current_line.pop()
|
|
137
124
|
|
|
138
|
-
|
|
139
|
-
|
|
125
|
+
self._lines.append(self._current_line)
|
|
126
|
+
self._current_line = []
|
|
140
127
|
else:
|
|
141
128
|
yield HeartbeatFrame()
|
|
142
129
|
|
|
143
130
|
else:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
previous_byte = byte
|
|
131
|
+
self._current_line.append(byte)
|
|
147
132
|
|
|
148
|
-
|
|
133
|
+
self._previous_byte = byte
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|