10BC0 wait_for_logs fails for DockerCompose · Issue #144 · testcontainers/testcontainers-python · GitHub
[go: up one dir, main page]

Skip to content

wait_for_logs fails for DockerCompose #144

@bitplane

Description

@bitplane

Example code:

    container = DockerCompose('.', dockerfile, pull=True)
    container.start()
    wait_for_logs(container, 'Connected with result code 0', timeout=60)

Output:

container = <testcontainers.compose.DockerCompose object at 0x10fd9a7c0>, predicate = <built-in method search of re.Pattern object at 0x7fe22e561000>, timeout = 60, interval = 1

    def wait_for_logs(container, predicate, timeout=None, interval=1):
        """
        Wait for the container to emit logs satisfying the predicate.
    
        Parameters
        ----------
        container : DockerContainer
            Container whose logs to wait for.
        predicate : callable or str
            Predicate that should be satisfied by the logs. If a string, the it is used as the pattern
            for a multiline regular expression search.
        timeout : float or None
            Number of seconds to wait for the predicate to be satisfied. Defaults to wait indefinitely.
        interval : float
            Interval at which to poll the logs.
    
        Returns
        -------
        duration : float
            Number of seconds until the predicate was satisfied.
        """
        if isinstance(predicate, str):
            predicate = re.compile(predicate, re.MULTILINE).search
        start = time.time()
        while True:
            duration = time.time() - start
>           if predicate(container._container.logs().decode()):
E           AttributeError: 'DockerCompose' object has no attribute '_container'

../../venv/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:87: AttributeError

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

      0