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

Possible issue with timeout in read_output_buffers #1303

Open
goetzk opened this issue Feb 25, 2025 · 0 comments
Open

Possible issue with timeout in read_output_buffers #1303

goetzk opened this issue Feb 25, 2025 · 0 comments

Comments

@goetzk
Copy link

goetzk commented Feb 25, 2025

Describe the bug

I'm not sure if timeout should be optional (per the functions interface) or mandatory but when i try to call it without timeout I see TypeError.

def read_output_buffers(
    stdout_buffer: Iterable,
    stderr_buffer: Iterable,
    timeout: Optional[int],
    print_output: bool,
    print_prefix: str,
) -> CommandOutput:
    output_queue: Queue[OutputLine] = Queue()
...
    # Wait on output, with our timeout (or None)
    greenlets = gevent.wait((stdout_reader, stderr_reader), timeout=timeout)

To Reproduce

Within run_shell_command in my connector I have the following block:

    status, stdout, stderr = self.lxd_api_client.execute_command(instance_name=api_name, commands=commands_to_run)

    logger.debug('{} run completed, status {}'.format(host.name, status))

    # TODO: set stderr/stdout to None if they are zero length? will that stop unnecessary blank lines in output?

    # Use read_output_buffers to process stdout/err into the format expected by the calling code within pyinfra
    # Provided output streams need to be supplied as lists.
    combined_output = read_output_buffers(
        [stdout],
        [stderr],
        # read_output_buffers definition says this is optional but it appears to be required within the function
        timeout=15,
        print_output=True,
        print_prefix=api_name,
    )

When run I have the following error:

  File "/home/kgoetz/source/pyinfra_lxc/pyinfra_lxc/connectors.py", line 193, in run_shell_command
    combined_output = read_output_buffers(
                      ^^^^^^^^^^^^^^^^^^^^
TypeError: read_output_buffers() missing 1 required positional argument: 'timeout'

Expected behavior

timeout optional/has default setting.

Meta

(pyinfra) kgoetz@L23001:~/source/pyinfra_tests$ pyinfra --support

    If you are having issues with pyinfra or wish to make feature requests, please
    check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
    When adding an issue, be sure to include the following:

    System: Linux
      Platform: Linux-6.1.0-31-amd64-x86_64-with-glibc2.36
      Release: 6.1.0-31-amd64
      Machine: x86_64
    pyinfra: v3.2
      click: v8.1.8
      coverage: v7.6.12
      coverage: v7.6.12
      distro: v1.9.0
      gevent: v24.11.1
      jinja2: v3.1.5
      packaging: v24.2
      paramiko: v3.5.1
      pytest: v8.3.4
      pytest: v8.3.4
      pytest-cov: v6.0.0
      pytest-cov: v6.0.0
      python-dateutil: v2.9.0.post0
      pywinrm: v0.5.0
      setuptools: v66.1.1
      typeguard: v4.4.1
      typing-extensions: v4.12.2
      wheel: v0.38.4
    Executable: /home/kgoetz/.venvs/pyinfra/bin/pyinfra
    Python: 3.11.2 (CPython, GCC 12.2.0)
(pyinfra) kgoetz@L23001:~/source/pyinfra_tests$ pip list |grep pyin
pyinfra             3.2
pyinfra_lxc         0.0.1       /home/kgoetz/source/pyinfra_lxc
(pyinfra) kgoetz@L23001:~/source/pyinfra_tests$ 
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