[Python] How to make robot framework SSHLibrary not call logger.log_background_messages() on...

Discussão em 'Python' iniciado por Stack, Maio 17, 2025.

  1. Stack

    Stack Membro Participativo

    I am in my keyword running some parallel tasks using concurrent.futures and using robotbackgroundlogger to log the messages. After all threads are finished I run logger.log_background_messages() in the main thread since it only allows running it in main thread.

    The problem is that SSHLibrary() automatically tries to call logger.log_background_messages() in it's close function.

    From the source code I can see the following snippet


    def close(self):
    """Closes the connection."""
    if self.tunnel:
    self.tunnel.close()
    self._sftp_client = None
    self._scp_transfer_client = None
    self._scp_all_client = None
    self._shell = None
    self.client.close()
    try:
    logger.log_background_messages()
    except AttributeError:
    pass​

    Which means that closing any SSH connection in a thread would raise an RuntimeError if you have robotbackgroundlogger installed, since you are not allowed to run the function logger.log_background_messages() unless in the main thread.

    How can I disable so that SSHLibrary does not try to run logger.log_background_messages when I close my SSH connection? Or some other workaround to make it work?

    Continue reading...

Compartilhe esta Página