stompman 3.3.0__tar.gz → 3.4.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.3.0 → stompman-3.4.0}/PKG-INFO +1 -1
- {stompman-3.3.0 → stompman-3.4.0}/stompman/connection_manager.py +19 -3
- {stompman-3.3.0 → stompman-3.4.0}/.gitignore +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/pyproject.toml +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/__init__.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/client.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/config.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/connection.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/connection_lifespan.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/errors.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/frames.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/logger.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/py.typed +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/serde.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/subscription.py +0 -0
- {stompman-3.3.0 → stompman-3.4.0}/stompman/transaction.py +0 -0
|
@@ -55,10 +55,12 @@ class ConnectionManager:
|
|
|
55
55
|
_reconnect_lock: asyncio.Lock = field(init=False, default_factory=asyncio.Lock)
|
|
56
56
|
_task_group: asyncio.TaskGroup = field(init=False, default_factory=asyncio.TaskGroup)
|
|
57
57
|
_send_heartbeat_task: asyncio.Task[None] = field(init=False, repr=False)
|
|
58
|
+
_check_server_heartbeat_task: asyncio.Task[None] = field(init=False, repr=False)
|
|
58
59
|
|
|
59
60
|
async def __aenter__(self) -> Self:
|
|
60
61
|
await self._task_group.__aenter__()
|
|
61
62
|
self._send_heartbeat_task = self._task_group.create_task(asyncio.sleep(0))
|
|
63
|
+
self._check_server_heartbeat_task = self._task_group.create_task(asyncio.sleep(0))
|
|
62
64
|
self._active_connection_state = await self._get_active_connection_state(is_initial_call=True)
|
|
63
65
|
return self
|
|
64
66
|
|
|
@@ -66,7 +68,8 @@ class ConnectionManager:
|
|
|
66
68
|
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
|
|
67
69
|
) -> None:
|
|
68
70
|
self._send_heartbeat_task.cancel()
|
|
69
|
-
|
|
71
|
+
self._check_server_heartbeat_task.cancel()
|
|
72
|
+
await asyncio.wait([self._send_heartbeat_task, self._check_server_heartbeat_task])
|
|
70
73
|
await self._task_group.__aexit__(exc_type, exc_value, traceback)
|
|
71
74
|
|
|
72
75
|
if not self._active_connection_state:
|
|
@@ -77,11 +80,15 @@ class ConnectionManager:
|
|
|
77
80
|
return
|
|
78
81
|
await self._active_connection_state.connection.close()
|
|
79
82
|
|
|
80
|
-
def
|
|
83
|
+
def _restart_heartbeat_tasks(self, server_heartbeat: Heartbeat) -> None:
|
|
81
84
|
self._send_heartbeat_task.cancel()
|
|
85
|
+
self._check_server_heartbeat_task.cancel()
|
|
82
86
|
self._send_heartbeat_task = self._task_group.create_task(
|
|
83
87
|
self._send_heartbeats_forever(server_heartbeat.want_to_receive_interval_ms)
|
|
84
88
|
)
|
|
89
|
+
self._check_server_heartbeat_task = self._task_group.create_task(
|
|
90
|
+
self._check_server_heartbeat_forever(server_heartbeat.will_send_interval_ms)
|
|
91
|
+
)
|
|
85
92
|
|
|
86
93
|
async def _send_heartbeats_forever(self, send_heartbeat_interval_ms: int) -> None:
|
|
87
94
|
send_heartbeat_interval_seconds = send_heartbeat_interval_ms / 1000
|
|
@@ -89,6 +96,15 @@ class ConnectionManager:
|
|
|
89
96
|
await self.write_heartbeat_reconnecting()
|
|
90
97
|
await asyncio.sleep(send_heartbeat_interval_seconds)
|
|
91
98
|
|
|
99
|
+
async def _check_server_heartbeat_forever(self, receive_heartbeat_interval_ms: int) -> None:
|
|
100
|
+
receive_heartbeat_interval_seconds = receive_heartbeat_interval_ms / 1000
|
|
101
|
+
while True:
|
|
102
|
+
await asyncio.sleep(receive_heartbeat_interval_seconds * self.check_server_alive_interval_factor)
|
|
103
|
+
if not self._active_connection_state:
|
|
104
|
+
continue
|
|
105
|
+
if not self._active_connection_state.is_alive(self.check_server_alive_interval_factor):
|
|
106
|
+
self._clear_active_connection_state()
|
|
107
|
+
|
|
92
108
|
async def _create_connection_to_one_server(
|
|
93
109
|
self, server: ConnectionParameters
|
|
94
110
|
) -> tuple[AbstractConnection, ConnectionParameters] | None:
|
|
@@ -119,7 +135,7 @@ class ConnectionManager:
|
|
|
119
135
|
lifespan = self.lifespan_factory(
|
|
120
136
|
connection=connection,
|
|
121
137
|
connection_parameters=connection_parameters,
|
|
122
|
-
set_heartbeat_interval=self.
|
|
138
|
+
set_heartbeat_interval=self._restart_heartbeat_tasks,
|
|
123
139
|
)
|
|
124
140
|
|
|
125
141
|
try:
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|