Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit 8447159

Browse files
authored
Prevent ServiceBrowser from collapsing when encountering a BadTypeInNameException (#254)
1 parent a25276a commit 8447159

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

netdisco/mdns.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""Add support for discovering mDNS services."""
2+
import logging
23
from typing import List # noqa: F401
34

4-
from zeroconf import (
5-
Zeroconf,
6-
ServiceBrowser,
7-
ServiceInfo,
8-
DNSRecord,
9-
DNSPointer,
10-
ServiceStateChange,
11-
)
5+
from zeroconf import DNSPointer, DNSRecord
6+
from zeroconf import Error as ZeroconfError
7+
from zeroconf import ServiceBrowser, ServiceInfo, ServiceStateChange, Zeroconf
8+
9+
_LOGGER = logging.getLogger(__name__)
1210

1311

1412
class FastServiceBrowser(ServiceBrowser):
@@ -51,7 +49,10 @@ def start(self):
5149
def _service_update(zeroconf, service_type, name, state_change):
5250
if state_change == ServiceStateChange.Added:
5351
for service in services_by_type[service_type]:
54-
service.add_service(zeroconf, service_type, name)
52+
try:
53+
service.add_service(zeroconf, service_type, name)
54+
except ZeroconfError:
55+
_LOGGER.exception("Failed to add service %s", name)
5556
elif state_change == ServiceStateChange.Removed:
5657
for service in services_by_type[service_type]:
5758
service.remove_service(zeroconf, service_type, name)

0 commit comments

Comments
 (0)