Commit 3052614a authored by Paris Stentoumis's avatar Paris Stentoumis
Browse files

feat: TFSDK error catch when probing. removed duplicate exception handler registration

parent eb19048c
Loading
Loading
Loading
Loading
Loading
+12 −0
Changes for src/srm/application/services/device_targeted_control_path.py: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ from srm.application.services.capability_placement import (
)
from srm.domain.models.canonical_parameters.parameters import Parameters
from srm.domain.models.topology import CapabilityKind, DomainKind
from srm.domain.ports import TFSDKError
from srm.domain.ports.transformation_functions import (
    ControlPathRegistry,
    ResolvedCapabilityTarget,
@@ -101,6 +102,7 @@ class DeviceTargetedControlPathResolver:
            # TF-SDK adapters are synchronous and talk to a backend over the network
            # (ADR-0024: in-process library). Calling one directly would block the event loop
            # for the whole round-trip, once per candidate.
            try:
                answer = await to_thread.run_sync(
                    adapter.can_serve_target,
                    TargetServeabilityRequest(
@@ -113,6 +115,16 @@ class DeviceTargetedControlPathResolver:
                        parameters=request.parameters,
                    ),
                )
            except TFSDKError as e:
                logger.exception(
                    "Error calling can_serve_target",
                    error_code=e.error_code,
                    error=e.message,
                    control_path_ref=placement.control_path_ref,
                    capability_kind=request.capability_kind,
                )
                unprobed_candidates = True
                continue
            if answer is TargetServeability.CAN_SERVE:
                return DeviceTargetedResolution(placement=placement)
            if answer is TargetServeability.UNKNOWN_SUBSCRIBER:
+0 −2
Changes for src/srm/main.py: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -127,8 +127,6 @@ def create_app() -> FastAPI:
    register_middlewares(app=app)
    register_exception_handlers(app=app)

    register_exception_handlers(app=app)

    # Add routers
    app.include_router(health_router)
    app.include_router(internal)