aristanetworks / anta

What do you call an ant with frogs legs?
https://anta.arista.com/
Apache License 2.0
46 stars 24 forks source link

`AntaInventory.connect_inventory()` has a broad exception catch #823

Open mtache opened 1 week ago

mtache commented 1 week ago

When writing unit tests, I rediscovered the connect_inventory() coroutine that returns all exceptions and do not stop gathering coroutines: https://github.com/aristanetworks/anta/blob/main/anta/inventory/__init__.py#L307

Error handling is done in the AntaDevice.refresh() function and if any Exception occurs, that should be propagated:

Suggested code:

    async def connect_inventory(self) -> None:
        """Run `refresh()` coroutines for all AntaDevice objects in this inventory."""
        logger.debug("Refreshing devices...")
        results = await asyncio.gather( *(device.refresh() for device in self.values()))