stompman 3.4.0__tar.gz → 3.6.0__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-3.4.0 → stompman-3.6.0}/PKG-INFO +1 -1
- {stompman-3.4.0 → stompman-3.6.0}/stompman/client.py +4 -1
- {stompman-3.4.0 → stompman-3.6.0}/stompman/connection.py +3 -5
- {stompman-3.4.0 → stompman-3.6.0}/stompman/connection_manager.py +13 -12
- {stompman-3.4.0 → stompman-3.6.0}/stompman/errors.py +2 -0
- {stompman-3.4.0 → stompman-3.6.0}/.gitignore +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/pyproject.toml +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/__init__.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/config.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/connection_lifespan.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/frames.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/logger.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/py.typed +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/serde.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/subscription.py +0 -0
- {stompman-3.4.0 → stompman-3.6.0}/stompman/transaction.py +0 -0
|
@@ -20,6 +20,7 @@ from stompman.frames import (
|
|
|
20
20
|
ReceiptFrame,
|
|
21
21
|
SendFrame,
|
|
22
22
|
)
|
|
23
|
+
from stompman.logger import LOGGER
|
|
23
24
|
from stompman.subscription import AckableMessageFrame, ActiveSubscriptions, AutoAckSubscription, ManualAckSubscription
|
|
24
25
|
from stompman.transaction import Transaction
|
|
25
26
|
|
|
@@ -29,7 +30,9 @@ class Client:
|
|
|
29
30
|
PROTOCOL_VERSION: ClassVar = "1.2" # https://stomp.github.io/stomp-specification-1.2.html
|
|
30
31
|
|
|
31
32
|
servers: list[ConnectionParameters] = field(kw_only=False)
|
|
32
|
-
on_error_frame: Callable[[ErrorFrame], Any] | None =
|
|
33
|
+
on_error_frame: Callable[[ErrorFrame], Any] | None = lambda error_frame: LOGGER.error(
|
|
34
|
+
"received error frame: %s", error_frame
|
|
35
|
+
)
|
|
33
36
|
|
|
34
37
|
heartbeat: Heartbeat = field(default=Heartbeat(1000, 1000))
|
|
35
38
|
ssl: Literal[True] | SSLContext | None = None
|
|
@@ -37,7 +37,7 @@ def _reraise_connection_lost(*causes: type[Exception]) -> Generator[None, None,
|
|
|
37
37
|
try:
|
|
38
38
|
yield
|
|
39
39
|
except causes as exception:
|
|
40
|
-
raise ConnectionLostError from exception
|
|
40
|
+
raise ConnectionLostError(reason=exception) from exception
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
@dataclass(kw_only=True, slots=True)
|
|
@@ -85,10 +85,8 @@ class Connection(AbstractConnection):
|
|
|
85
85
|
await self.writer.drain()
|
|
86
86
|
|
|
87
87
|
async def _read_non_empty_bytes(self, max_chunk_size: int) -> bytes:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
) == b"": # pragma: no cover (it definitely happens)
|
|
91
|
-
await asyncio.sleep(0)
|
|
88
|
+
if (chunk := await self.reader.read(max_chunk_size)) == b"":
|
|
89
|
+
raise ConnectionLostError(reason="eof")
|
|
92
90
|
return chunk
|
|
93
91
|
|
|
94
92
|
async def read_frames(self) -> AsyncGenerator[AnyServerFrame, None]:
|
|
@@ -103,7 +103,7 @@ class ConnectionManager:
|
|
|
103
103
|
if not self._active_connection_state:
|
|
104
104
|
continue
|
|
105
105
|
if not self._active_connection_state.is_alive(self.check_server_alive_interval_factor):
|
|
106
|
-
self._clear_active_connection_state()
|
|
106
|
+
self._clear_active_connection_state(ConnectionLostError(reason="server heartbeat timeout"))
|
|
107
107
|
|
|
108
108
|
async def _create_connection_to_one_server(
|
|
109
109
|
self, server: ConnectionParameters
|
|
@@ -168,7 +168,7 @@ class ConnectionManager:
|
|
|
168
168
|
self._active_connection_state = connection_result
|
|
169
169
|
if not is_initial_call:
|
|
170
170
|
LOGGER.warning(
|
|
171
|
-
"reconnected after
|
|
171
|
+
"reconnected after connection failure. connection_parameters: %s",
|
|
172
172
|
connection_result.lifespan.connection_parameters,
|
|
173
173
|
)
|
|
174
174
|
return connection_result
|
|
@@ -178,11 +178,12 @@ class ConnectionManager:
|
|
|
178
178
|
|
|
179
179
|
raise FailedAllConnectAttemptsError(retry_attempts=self.connect_retry_attempts, issues=connection_issues)
|
|
180
180
|
|
|
181
|
-
def _clear_active_connection_state(self) -> None:
|
|
181
|
+
def _clear_active_connection_state(self, error_reason: ConnectionLostError) -> None:
|
|
182
182
|
if not self._active_connection_state:
|
|
183
183
|
return
|
|
184
184
|
LOGGER.warning(
|
|
185
|
-
"connection lost. connection_parameters: %s",
|
|
185
|
+
"connection lost. reason: %s, connection_parameters: %s",
|
|
186
|
+
error_reason.reason,
|
|
186
187
|
self._active_connection_state.lifespan.connection_parameters,
|
|
187
188
|
)
|
|
188
189
|
self._active_connection_state = None
|
|
@@ -192,8 +193,8 @@ class ConnectionManager:
|
|
|
192
193
|
connection_state = await self._get_active_connection_state()
|
|
193
194
|
try:
|
|
194
195
|
return connection_state.connection.write_heartbeat()
|
|
195
|
-
except ConnectionLostError:
|
|
196
|
-
self._clear_active_connection_state()
|
|
196
|
+
except ConnectionLostError as error:
|
|
197
|
+
self._clear_active_connection_state(error)
|
|
197
198
|
|
|
198
199
|
raise FailedAllWriteAttemptsError(retry_attempts=self.write_retry_attempts)
|
|
199
200
|
|
|
@@ -202,8 +203,8 @@ class ConnectionManager:
|
|
|
202
203
|
connection_state = await self._get_active_connection_state()
|
|
203
204
|
try:
|
|
204
205
|
return await connection_state.connection.write_frame(frame)
|
|
205
|
-
except ConnectionLostError:
|
|
206
|
-
self._clear_active_connection_state()
|
|
206
|
+
except ConnectionLostError as error:
|
|
207
|
+
self._clear_active_connection_state(error)
|
|
207
208
|
|
|
208
209
|
raise FailedAllWriteAttemptsError(retry_attempts=self.write_retry_attempts)
|
|
209
210
|
|
|
@@ -213,15 +214,15 @@ class ConnectionManager:
|
|
|
213
214
|
try:
|
|
214
215
|
async for frame in connection_state.connection.read_frames():
|
|
215
216
|
yield frame
|
|
216
|
-
except ConnectionLostError:
|
|
217
|
-
self._clear_active_connection_state()
|
|
217
|
+
except ConnectionLostError as error:
|
|
218
|
+
self._clear_active_connection_state(error)
|
|
218
219
|
|
|
219
220
|
async def maybe_write_frame(self, frame: AnyClientFrame) -> bool:
|
|
220
221
|
if not self._active_connection_state:
|
|
221
222
|
return False
|
|
222
223
|
try:
|
|
223
224
|
await self._active_connection_state.connection.write_frame(frame)
|
|
224
|
-
except ConnectionLostError:
|
|
225
|
-
self._clear_active_connection_state()
|
|
225
|
+
except ConnectionLostError as error:
|
|
226
|
+
self._clear_active_connection_state(error)
|
|
226
227
|
return False
|
|
227
228
|
return True
|
|
@@ -14,6 +14,8 @@ class Error(Exception):
|
|
|
14
14
|
class ConnectionLostError(Error):
|
|
15
15
|
"""Raised in stompman.AbstractConnection—and handled in stompman.ConnectionManager, therefore is private."""
|
|
16
16
|
|
|
17
|
+
reason: Exception | str
|
|
18
|
+
|
|
17
19
|
|
|
18
20
|
@dataclass(frozen=True, kw_only=True, slots=True)
|
|
19
21
|
class ConnectionConfirmationTimeout:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|