Skip to content

Commit

Permalink
reduce default wait durations on proxy start ups; reduce start up spam
Browse files Browse the repository at this point in the history
  • Loading branch information
David Conner committed Aug 25, 2024
1 parent 82f9aa8 commit a9f0423
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions flexbe_core/flexbe_core/proxy/proxy_action_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def shutdown():
except Exception as exc: # pylint: disable=W0703
print(f'Something went wrong during shutdown of proxy action clients!\n{ str(exc)}')

def __init__(self, topics=None, wait_duration=10):
def __init__(self, topics=None, wait_duration=1.0):
"""
Initialize the proxy with optionally a given set of clients.
Initialize the proxy with an optionally given set of clients.
@type topics: dictionary string - message class
@param topics: A dictionay containing a collection of topic - message type pairs.
Expand All @@ -104,10 +104,10 @@ def __init__(self, topics=None, wait_duration=10):
ProxyActionClient.setup_client(topic, action_type, wait_duration)

@classmethod
def setupClient(cls, topic, action_type, wait_duration=10):
def setupClient(cls, topic, action_type, wait_duration=1.0):
"""Set up proxy action client (Deprecated)."""
Logger.localerr('Deprecated: Use ProxyActionClient.setup_client instead!')
cls.setup_client(topic, action_type, wait_duration=10)
cls.setup_client(topic, action_type, wait_duration)

@classmethod
def setup_client(cls, topic, action_type, wait_duration=None):
Expand Down
8 changes: 4 additions & 4 deletions flexbe_core/flexbe_core/proxy/proxy_service_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ def shutdown():
except Exception as exc: # pylint: disable=W0703
print(f'Something went wrong during shutdown of proxy service caller !\n{str(exc)}')

def __init__(self, topics=None, wait_duration=10):
def __init__(self, topics=None, wait_duration=1.0):
"""
Initialize the proxy with optionally a given set of clients.
@type topics: dictionary string - message class
@param topics: A dictionary containing a collection of topic - message type pairs.
@type wait_duration: float
@param wait_duration: Defines how long to wait (seconds) for the given services if not available right now.
@param wait_duration: Defines how long to wait (seconds) for the given service if not available right now.
"""
if topics is not None:
for topic, srv_type in topics.items():
ProxyServiceCaller.setup_service(topic, srv_type, wait_duration)

@classmethod
def setupService(cls, topic, srv_type, wait_duration=10):
def setupService(cls, topic, srv_type, wait_duration=1.0):
"""Set up the service caller."""
Logger.localerr('Deprecated: Use ProxyServiceCaller.setup_service instead!')
cls.setup_service(topic, srv_type, wait_duration)
Expand Down Expand Up @@ -267,7 +267,7 @@ def result(cls, topic):
return ProxyServiceCaller._results[topic].result()

@classmethod
def _check_service_available(cls, topic, wait_duration=1):
def _check_service_available(cls, topic, wait_duration=1.0):
"""
Check whether a service is available.
Expand Down
22 changes: 11 additions & 11 deletions flexbe_core/flexbe_core/proxy/proxy_subscriber_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def subscribe(self, topic, msg_type, callback=None, buffered=False, qos=None, in
'callbacks': defaultdict(None),
'subscribers': [inst_id]}

Logger.localinfo(f"Created subscription for '{topic}' with message type '{msg_type.__name__}'!")
# Logger.localinfo(f"Created subscription for '{topic}' with message type '{msg_type.__name__}'!")

else:
with ProxySubscriberCached._subscription_lock:
Expand All @@ -147,24 +147,24 @@ def subscribe(self, topic, msg_type, callback=None, buffered=False, qos=None, in
# ' - keep existing subscriber! ('
# f"{len(ProxySubscriberCached._topics[topic]['subscribers'])})")
ProxySubscriberCached._topics[topic]['subscribers'].append(inst_id)
else:
Logger.localinfo(f"Existing subscription for '{topic}' with same message type name"
' - keep existing subscriber! '
f"({len(ProxySubscriberCached._topics[topic]['subscribers'])})")
# else:
# Logger.localinfo(f"Existing subscription for '{topic}' with same message type name"
# ' - keep existing subscriber! '
# f"({len(ProxySubscriberCached._topics[topic]['subscribers'])})")
else:
Logger.info(f'Mis-matched msg_types ({msg_type.__name__} vs. '
f"{ProxySubscriberCached._topics[topic]['subscription'].msg_type.__name__})"
f" for '{topic}' subscription (possibly due to reload of behavior)!")
raise TypeError(f"Trying to replace existing subscription with different msg type for '{topic}'")
else:
if inst_id not in ProxySubscriberCached._topics[topic]['subscribers']:
Logger.localinfo(f"Add subscriber to existing subscription for '{topic}'! "
f"({len(ProxySubscriberCached._topics[topic]['subscribers'])})")
# Logger.localinfo(f"Add subscriber to existing subscription for '{topic}'! "
# f"({len(ProxySubscriberCached._topics[topic]['subscribers'])})")
ProxySubscriberCached._topics[topic]['subscribers'].append(inst_id)
else:
Logger.localinfo(f"Existing subscription for '{topic}' with same message type "
'- keep existing subscriber! '
f"({len(ProxySubscriberCached._topics[topic]['subscribers'])})")
# else:
# Logger.localinfo(f"Existing subscription for '{topic}' with same message type "
# '- keep existing subscriber! '
# f"({len(ProxySubscriberCached._topics[topic]['subscribers'])})")

# Register the local callback for topic message
if callback is not None:
Expand Down

0 comments on commit a9f0423

Please sign in to comment.