diff --git a/python/lsst/ap/association/packageAlerts.py b/python/lsst/ap/association/packageAlerts.py index 26078b70..5fd17848 100644 --- a/python/lsst/ap/association/packageAlerts.py +++ b/python/lsst/ap/association/packageAlerts.py @@ -575,12 +575,19 @@ def _delivery_callback(self, err, msg): self.log.debug('Message delivered to %s [%d] @ %d', msg.topic(), msg.partition(), msg.offset()) def _server_check(self): - try: - admin_client = AdminClient(self.kafkaAdminConfig) - topics = admin_client.list_topics(timeout=0.5).topics - - if not topics: - raise RuntimeError() - - except KafkaException as exception: - raise exception + """Checks if the alert stream credentials are still valid and the + server is contactable. + + Raises + ------- + KafkaException + Raised if the server us not contactable. + RuntimeError + Raised if the server is contactable but there are no topics + present. + """ + admin_client = AdminClient(self.kafkaAdminConfig) + topics = admin_client.list_topics(timeout=0.5).topics + + if not topics: + raise RuntimeError()