Skip to content

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

Closed
@orhantugrul

Description

@orhantugrul

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions