Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
orhantugrul opened this issue Sep 5, 2024 · 0 comments
Open

Comments

@orhantugrul
Copy link

orhantugrul commented Sep 5, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant