zabbix / python-zabbix-utils

Python library "zabbix-utils"
MIT License
114 stars 16 forks source link

AsyncZabbixAPI can't be used in `with` statement like ZabbixAPI #18

Open orhantugrul opened 3 months ago

orhantugrul commented 3 months ago

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

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