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