Skip to content

join raises error when exception occurs despite having stop_on_error=False #52

@iameugenejo

Description

@iameugenejo

I got this error after using client.join after calling run_command(..., stop_on_error=False):

  File ".../env/lib/python2.7/site-packages/pssh/pssh_client.py", line 404, in join
    for line in output[host]['stdout']:
TypeError: 'NoneType' object is not iterable

so decided to manually wait for stdout, then I get this error:

  File ".../env/lib/python2.7/site-packages/pssh/pssh_client.py", line 416, in get_exit_codes
    output[host].update({'exit_code': self.get_exit_code(output[host])})
  File ".../env/lib/python2.7/site-packages/pssh/pssh_client.py", line 428, in get_exit_code
    return self._get_exit_code(channel)
  File ".../env/lib/python2.7/site-packages/pssh/pssh_client.py", line 432, in _get_exit_code
    if not channel.exit_status_ready():
AttributeError: 'NoneType' object has no attribute 'exit_status_ready'

The problematic code blocks:

def join(self, output):
    """Block until all remote commands in output have finished
    and retrieve exit codes"""
    for host in output:
        for line in output[host]['stdout']:
            pass
    self.get_exit_codes(output)

def _get_exit_code(self, channel):
        """Get exit code from channel if ready"""
        if not channel.exit_status_ready():
            return
        channel.close()
        return channel.recv_exit_status()

shouldn't above be below?

def join(self, output):
    """Block until all remote commands in output have finished
    and retrieve exit codes"""
    for host in output:
        stdout = output[host].get('stdout')
        if stdout:
            for _ in stdout:
                pass

    self.get_exit_codes(output)

def _get_exit_code(self, channel):
        """Get exit code from channel if ready"""
        if not channel or not channel.exit_status_ready():
            return
        channel.close()
        return channel.recv_exit_status()

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