Skip to content

Commit

Permalink
fix: add error handling for connect error during config.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmario committed Oct 11, 2024
1 parent c977c16 commit ffb597d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions metricq_source_modbus/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,25 @@ async def _create_from_host_config(
h, host_config.port, host_config.slave_id, host_config.strings
)
for h in hosts
)
),
return_exceptions=True,
)
assert len(hosts) == len(replacers)

for host, name, description, replacer in zip(
hosts, names, descriptions, replacers
):
yield Host(
source=source,
host=host,
name=name,
description=description,
replacer=replacer,
config=host_config,
)
if not isinstance(replacer, Exception):
yield Host(
source=source,
host=host,
name=name,
description=description,
replacer=replacer,
config=host_config,
)
else:
logger.error(f"Failed to connect to: {host} ({name}). Skipping.")

@classmethod
async def create_from_host_configs(
Expand Down

0 comments on commit ffb597d

Please sign in to comment.