The AsyncZabbixAPI class cannot be used in a with statement like the ZabbixAPI class. This is due to a difference in the initialization process between the two classes.
Current Behavior
ZabbixAPI automatically logs in during the __init__ function.
AsyncZabbixAPI does not automatically log in during initialization.
Expected Behavior
Users expect to be able to use AsyncZabbixAPI in a with statement similar to ZabbixAPI for consistent usage patterns.
Proposed Solution
Perform the asynchronous login in the __aenter__ method.
class AsyncZabbixAPI:
async def __aenter__(self):
await self.login()
return self