File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
src/nipanel/streamlit_refresh Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5+ import threading
6+
57from ni_measurement_plugin_sdk_service .discovery import DiscoveryClient
68from ni_measurement_plugin_sdk_service .grpc .channelpool import GrpcChannelPool
79from streamlit .components .v1 import declare_component
@@ -24,13 +26,15 @@ def initialize_refresh_component(panel_id: str) -> CustomComponent:
2426
2527
2628def _get_or_resolve_proxy () -> str :
27- global _panel_service_proxy_location
28- if _panel_service_proxy_location is None :
29- discovery_client = DiscoveryClient (grpc_channel_pool = GrpcChannelPool ())
30- service_location = discovery_client .resolve_service (
31- provided_interface = "ni.http1.proxy" ,
32- service_class = "" ,
33- )
34- _panel_service_proxy_location = service_location .insecure_address
35-
36- return _panel_service_proxy_location
29+ with threading .RLock ():
30+ global _panel_service_proxy_location
31+ if _panel_service_proxy_location is None :
32+ with GrpcChannelPool () as grpc_channel_pool :
33+ discovery_client = DiscoveryClient (grpc_channel_pool = grpc_channel_pool )
34+ service_location = discovery_client .resolve_service (
35+ provided_interface = "ni.http1.proxy" ,
36+ service_class = "" ,
37+ )
38+ _panel_service_proxy_location = service_location .insecure_address
39+
40+ return _panel_service_proxy_location
You can’t perform that action at this time.
0 commit comments