@@ -105,7 +105,6 @@ def __init__(
105
105
self .thread_credentials_set : bool = False
106
106
self .compressed_fabric_id : int | None = None
107
107
self ._node_lock : dict [int , asyncio .Lock ] = {}
108
- self ._node_setup_lock : asyncio .Semaphore = asyncio .Semaphore (5 )
109
108
self ._aiobrowser : AsyncServiceBrowser | None = None
110
109
self ._aiozc : AsyncZeroconf | None = None
111
110
self ._sdk_executor = ThreadPoolExecutor (max_workers = 1 )
@@ -1036,51 +1035,45 @@ async def _setup_node(self, node_id: int) -> None:
1036
1035
# prevent duplicate setup actions
1037
1036
return
1038
1037
self ._nodes_in_setup .add (node_id )
1039
- # ping the node to out stale mdns reports and to prevent that we
1040
- # send an unreachable node to the sdk which is very slow with resolving it
1041
- # this will also precache the ip addresses of the node for later use.
1042
- ping_result = await self .ping_node (node_id )
1043
- if not any (ping_result .values ()):
1044
- LOGGER .warning (
1045
- "Skip set-up for node %s because it does not appear to be reachable..." ,
1046
- node_id ,
1047
- )
1048
- return
1049
- # we use a lock for the node setup process to process nodes sequentially
1050
- # to prevent a flood of the (thread) network when there are many nodes being setup.
1051
- async with self ._node_setup_lock :
1052
- # add this little random sleep here to do a bit of throttling
1053
- # can be optimized later
1054
- await asyncio .sleep (randint (0 , 5 )) # noqa: S311
1038
+ try :
1039
+ # ping the node to out stale mdns reports and to prevent that we
1040
+ # send an unreachable node to the sdk which is very slow with resolving it
1041
+ # this will also precache the ip addresses of the node for later use.
1042
+ ping_result = await self .ping_node (node_id )
1043
+ if not any (ping_result .values ()):
1044
+ LOGGER .warning (
1045
+ "Skip set-up for node %s because it does not appear to be reachable..." ,
1046
+ node_id ,
1047
+ )
1048
+ return
1055
1049
LOGGER .info ("Setting-up node %s..." , node_id )
1056
- try :
1057
- # (re)interview node (only) if needed
1058
- node_data = self ._nodes [node_id ]
1059
- if (
1060
- # re-interview if we dont have any node attributes (empty node)
1061
- not node_data .attributes
1062
- # re-interview if the data model schema has changed
1063
- or node_data .interview_version != DATA_MODEL_SCHEMA_VERSION
1064
- ):
1065
- try :
1066
- await self .interview_node (node_id )
1067
- except (NodeNotResolving , NodeInterviewFailed ) as err :
1068
- LOGGER .warning ("Unable to interview Node %s" , exc_info = err )
1069
- # NOTE: the node will be picked up by mdns discovery automatically
1070
- # when it comes available again.
1071
- return
1072
- # setup subscriptions for the node
1050
+ # (re)interview node (only) if needed
1051
+ node_data = self ._nodes [node_id ]
1052
+ if (
1053
+ # re-interview if we dont have any node attributes (empty node)
1054
+ not node_data .attributes
1055
+ # re-interview if the data model schema has changed
1056
+ or node_data .interview_version != DATA_MODEL_SCHEMA_VERSION
1057
+ ):
1073
1058
try :
1074
- await self ._subscribe_node (node_id )
1075
- except NodeNotResolving :
1076
- LOGGER .warning (
1077
- "Unable to subscribe to Node %s as it is unavailable" ,
1078
- node_id ,
1079
- )
1059
+ await self .interview_node (node_id )
1060
+ except (NodeNotResolving , NodeInterviewFailed ) as err :
1061
+ LOGGER .warning ("Unable to interview Node %s" , exc_info = err )
1080
1062
# NOTE: the node will be picked up by mdns discovery automatically
1081
- # when it becomes available again.
1082
- finally :
1083
- self ._nodes_in_setup .discard (node_id )
1063
+ # when it comes available again.
1064
+ return
1065
+ # setup subscriptions for the node
1066
+ try :
1067
+ await self ._subscribe_node (node_id )
1068
+ except NodeNotResolving :
1069
+ LOGGER .warning (
1070
+ "Unable to subscribe to Node %s as it is unavailable" ,
1071
+ node_id ,
1072
+ )
1073
+ # NOTE: the node will be picked up by mdns discovery automatically
1074
+ # when it becomes available again.
1075
+ finally :
1076
+ self ._nodes_in_setup .discard (node_id )
1084
1077
1085
1078
async def _resolve_node (
1086
1079
self , node_id : int , retries : int = 2 , attempt : int = 1
0 commit comments