cgse-core 0.17.2__py3-none-any.whl → 0.17.3__py3-none-any.whl
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.
- {cgse_core-0.17.2.dist-info → cgse_core-0.17.3.dist-info}/METADATA +1 -1
- {cgse_core-0.17.2.dist-info → cgse_core-0.17.3.dist-info}/RECORD +11 -17
- egse/connect.py +4 -477
- egse/dummy.py +3 -19
- egse/logger/__init__.py +2 -2
- egse/notifyhub/server.py +1 -3
- egse/registry/client.py +3 -9
- egse/registry/server.py +3 -11
- egse/registry/service.py +5 -11
- egse/async_control.py +0 -1085
- egse/async_control_claude.py +0 -807
- egse/confman/confman_acs.py +0 -35
- egse/metricshub/__init__.py +0 -0
- egse/metricshub/server.py +0 -271
- egse/notifyhub/test.py +0 -303
- {cgse_core-0.17.2.dist-info → cgse_core-0.17.3.dist-info}/WHEEL +0 -0
- {cgse_core-0.17.2.dist-info → cgse_core-0.17.3.dist-info}/entry_points.txt +0 -0
egse/notifyhub/server.py
CHANGED
|
@@ -23,12 +23,10 @@ from egse.notifyhub import SERVICE_TYPE
|
|
|
23
23
|
from egse.notifyhub import STATS_INTERVAL
|
|
24
24
|
from egse.notifyhub.client import AsyncNotificationHubClient
|
|
25
25
|
from egse.registry import MessageType
|
|
26
|
-
from egse.registry.client import REQUEST_TIMEOUT
|
|
27
|
-
from egse.registry.client import AsyncRegistryClient
|
|
26
|
+
from egse.registry.client import AsyncRegistryClient, REQUEST_TIMEOUT
|
|
28
27
|
from egse.system import TyperAsyncCommand
|
|
29
28
|
from egse.system import get_host_ip
|
|
30
29
|
from egse.zmq_ser import get_port_number
|
|
31
|
-
|
|
32
30
|
from .event import NotificationEvent
|
|
33
31
|
|
|
34
32
|
REQUEST_POLL_TIMEOUT = 1.0
|
egse/registry/client.py
CHANGED
|
@@ -639,8 +639,6 @@ class AsyncRegistryClient:
|
|
|
639
639
|
The response from the registry as a dictionary.
|
|
640
640
|
"""
|
|
641
641
|
|
|
642
|
-
assert self.req_socket is not None, "REQ socket is not connected, cannot send request."
|
|
643
|
-
|
|
644
642
|
timeout = timeout or self.timeout
|
|
645
643
|
try:
|
|
646
644
|
self.logger.debug(f"Sending request: {request}")
|
|
@@ -689,8 +687,6 @@ class AsyncRegistryClient:
|
|
|
689
687
|
The response from the registry as a dictionary.
|
|
690
688
|
"""
|
|
691
689
|
|
|
692
|
-
assert self.hb_socket is not None, "HB socket is not connected, cannot send heartbeat request."
|
|
693
|
-
|
|
694
690
|
try:
|
|
695
691
|
self.logger.debug(f"Sending heartbeat request: {request}")
|
|
696
692
|
await self.hb_socket.send_string(json.dumps(request))
|
|
@@ -871,8 +867,7 @@ class AsyncRegistryClient:
|
|
|
871
867
|
await self.reregister()
|
|
872
868
|
|
|
873
869
|
else:
|
|
874
|
-
|
|
875
|
-
self.logger.debug(f"Heartbeat succeeded: {response.get('message')}")
|
|
870
|
+
VERBOSE_DEBUG and self.logger.debug(f"Heartbeat succeeded: {response.get('message')}")
|
|
876
871
|
|
|
877
872
|
except Exception as exc:
|
|
878
873
|
self.logger.error(f"Error in heartbeat loop: {exc}", exc_info=True)
|
|
@@ -905,7 +900,6 @@ class AsyncRegistryClient:
|
|
|
905
900
|
try:
|
|
906
901
|
await self._heartbeat_task
|
|
907
902
|
except asyncio.CancelledError:
|
|
908
|
-
self.logger.info("Heartbeat task cancelled")
|
|
909
903
|
pass
|
|
910
904
|
self._tasks.discard(self._heartbeat_task)
|
|
911
905
|
self._heartbeat_task = None
|
|
@@ -1152,8 +1146,8 @@ class AsyncRegistryClient:
|
|
|
1152
1146
|
if hasattr(self, "context") and self.context:
|
|
1153
1147
|
self.logger.info(f"{self.context = !r}")
|
|
1154
1148
|
self.logger.info(f"{self.context._sockets = !r}")
|
|
1155
|
-
|
|
1156
|
-
|
|
1149
|
+
if not self.context.closed:
|
|
1150
|
+
self.context.term()
|
|
1157
1151
|
except Exception as exc:
|
|
1158
1152
|
self.logger.error(f"Error during cleanup: {exc}")
|
|
1159
1153
|
|
egse/registry/server.py
CHANGED
|
@@ -218,18 +218,16 @@ class AsyncRegistryServer:
|
|
|
218
218
|
"""Task that handles incoming requests."""
|
|
219
219
|
self.logger.info("Started request handler task")
|
|
220
220
|
|
|
221
|
-
assert self.req_socket is not None, "REQ socket is not connected, cannot handle requests."
|
|
222
|
-
|
|
223
221
|
try:
|
|
224
222
|
message_parts = None
|
|
225
223
|
while self._running:
|
|
226
224
|
try:
|
|
227
225
|
# Wait for a request with timeout to allow checking if still running
|
|
228
226
|
try:
|
|
229
|
-
self.logger.info("Waiting for a request with 1s timeout...")
|
|
227
|
+
# self.logger.info("Waiting for a request with 1s timeout...")
|
|
230
228
|
message_parts = await asyncio.wait_for(self.req_socket.recv_multipart(), timeout=1.0)
|
|
231
229
|
except asyncio.TimeoutError:
|
|
232
|
-
self.logger.debug("waiting for command request...")
|
|
230
|
+
# self.logger.debug("waiting for command request...")
|
|
233
231
|
continue
|
|
234
232
|
|
|
235
233
|
if len(message_parts) >= 3:
|
|
@@ -243,9 +241,6 @@ class AsyncRegistryServer:
|
|
|
243
241
|
response = await self._process_request(message_data)
|
|
244
242
|
|
|
245
243
|
await self._send_response(client_id, message_type, response)
|
|
246
|
-
else:
|
|
247
|
-
self.logger.warning("Request handler: message corrupted, check debug messages.")
|
|
248
|
-
self.logger.debug(f"{message_parts=}")
|
|
249
244
|
|
|
250
245
|
except zmq.ZMQError as exc:
|
|
251
246
|
self.logger.error(f"ZMQ error: {exc}", exc_info=True)
|
|
@@ -402,8 +397,6 @@ class AsyncRegistryServer:
|
|
|
402
397
|
"""Task that handles heartbeat messages."""
|
|
403
398
|
self.logger.info("Started heartbeats handler task")
|
|
404
399
|
|
|
405
|
-
assert self.hb_socket is not None, "HB socket is not connected, cannot handle heartbeat messages."
|
|
406
|
-
|
|
407
400
|
try:
|
|
408
401
|
message_parts = None
|
|
409
402
|
while self._running:
|
|
@@ -432,8 +425,7 @@ class AsyncRegistryServer:
|
|
|
432
425
|
self.logger.warning("Heartbeat request: message corrupted, check debug messages.")
|
|
433
426
|
|
|
434
427
|
except asyncio.TimeoutError:
|
|
435
|
-
|
|
436
|
-
self.logger.debug("waiting for heartbeat...")
|
|
428
|
+
VERBOSE_DEBUG and self.logger.debug("waiting for heartbeat...")
|
|
437
429
|
continue
|
|
438
430
|
|
|
439
431
|
except Exception as exc:
|
egse/registry/service.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
|
+
import logging
|
|
5
6
|
import time
|
|
6
7
|
from typing import Any
|
|
7
8
|
from typing import Callable
|
|
@@ -9,14 +10,13 @@ from typing import Callable
|
|
|
9
10
|
import zmq
|
|
10
11
|
import zmq.asyncio
|
|
11
12
|
|
|
12
|
-
from egse.log import logging
|
|
13
13
|
from egse.registry import DEFAULT_RS_PUB_PORT
|
|
14
14
|
from egse.registry import DEFAULT_RS_REQ_PORT
|
|
15
15
|
from egse.registry.client import AsyncRegistryClient
|
|
16
16
|
from egse.system import get_host_ip
|
|
17
17
|
from egse.zmq_ser import get_port_number
|
|
18
18
|
|
|
19
|
-
module_module_logger_name = "
|
|
19
|
+
module_module_logger_name = "async_microservice"
|
|
20
20
|
module_logger = logging.getLogger(module_module_logger_name)
|
|
21
21
|
|
|
22
22
|
|
|
@@ -64,7 +64,7 @@ class ZMQMicroservice:
|
|
|
64
64
|
self.registry_sub_endpoint = registry_sub_endpoint or f"tcp://localhost:{DEFAULT_RS_PUB_PORT}"
|
|
65
65
|
self.metadata = metadata or {}
|
|
66
66
|
|
|
67
|
-
self.host_ip = get_host_ip()
|
|
67
|
+
self.host_ip = get_host_ip()
|
|
68
68
|
|
|
69
69
|
# Service ID will be set when registered
|
|
70
70
|
self.service_id = None
|
|
@@ -164,7 +164,6 @@ class ZMQMicroservice:
|
|
|
164
164
|
|
|
165
165
|
if not self.service_id:
|
|
166
166
|
module_logger.error("Failed to register with the service registry")
|
|
167
|
-
await self._cleanup()
|
|
168
167
|
return True
|
|
169
168
|
|
|
170
169
|
module_logger.info(f"Registered with service ID: {self.service_id}")
|
|
@@ -176,17 +175,12 @@ class ZMQMicroservice:
|
|
|
176
175
|
# Start request handler
|
|
177
176
|
request_task = asyncio.create_task(self._handle_requests())
|
|
178
177
|
self._tasks.add(request_task)
|
|
179
|
-
|
|
178
|
+
request_task.add_done_callback(self._tasks.discard)
|
|
180
179
|
|
|
181
180
|
# Wait for shutdown signal
|
|
182
181
|
await self._shutdown.wait()
|
|
183
182
|
|
|
184
|
-
#
|
|
185
|
-
# try:
|
|
186
|
-
# await request_task
|
|
187
|
-
# except asyncio.CancelledError:
|
|
188
|
-
# module_logger.info("Request handler task cancelled during shutdown")
|
|
189
|
-
|
|
183
|
+
# Clean shutdown
|
|
190
184
|
await self._cleanup()
|
|
191
185
|
|
|
192
186
|
return False
|