mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-30 22:54:18 +00:00 
			
		
		
		
	ssh: making execute() thread safe.
This commit is contained in:
		| @@ -17,6 +17,7 @@ | ||||
| import logging | ||||
| import subprocess | ||||
| import re | ||||
| import threading | ||||
|  | ||||
| import pxssh | ||||
| from pexpect import EOF, TIMEOUT, spawn | ||||
| @@ -88,6 +89,7 @@ class SshShell(object): | ||||
|         self.password_prompt = password_prompt if password_prompt is not None else self.default_password_prompt | ||||
|         self.timeout = timeout | ||||
|         self.conn = None | ||||
|         self.lock = threading.Lock() | ||||
|  | ||||
|     def login(self, host, username, password=None, keyfile=None, port=None, timeout=None, telnet=False): | ||||
|         # pylint: disable=attribute-defined-outside-init | ||||
| @@ -118,6 +120,7 @@ class SshShell(object): | ||||
|         return subprocess.Popen(command, stdout=stdout, stderr=stderr, shell=True) | ||||
|  | ||||
|     def execute(self, command, timeout=None, check_exit_code=True, as_root=False, strip_colors=True): | ||||
|         with self.lock: | ||||
|             output = self._execute_and_wait_for_prompt(command, timeout, as_root, strip_colors) | ||||
|             if check_exit_code: | ||||
|                 exit_code = int(self._execute_and_wait_for_prompt('echo $?', strip_colors=strip_colors, log=False)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user