diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-10-23 15:53:33 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-10-23 17:40:16 +0900 |
| commit | 42272ffdb1541cf96f13466446e07c24d8e7febb (patch) | |
| tree | cc3fcbf997f33e851fc60d8d5a1774a74e66d5ef /pygerrit/ssh.py | |
| parent | e81b56eef5c10c012dc395bf978a793069de786e (diff) | |
| download | pygerrit-42272ffdb1541cf96f13466446e07c24d8e7febb.tar.gz | |
Basic thread-safeness in the SSH client
Add a lock around calls to the run_gerrit_command method.
Change-Id: I9429ed880e14a4248b08937969f8faebc2240f79
Diffstat (limited to 'pygerrit/ssh.py')
| -rw-r--r-- | pygerrit/ssh.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py index a675b47..fad32ed 100644 --- a/pygerrit/ssh.py +++ b/pygerrit/ssh.py @@ -25,6 +25,7 @@ THE SOFTWARE. """ from os.path import abspath, expanduser, isfile +from threading import Lock from pygerrit.error import GerritError @@ -39,6 +40,7 @@ class GerritSSHClient(SSHClient): """ Initialise and connect to SSH. """ super(GerritSSHClient, self).__init__() self.load_system_host_keys() + self.lock = Lock() configfile = expanduser("~/.ssh/config") if not isfile(configfile): @@ -78,4 +80,7 @@ class GerritSSHClient(SSHClient): gerrit_command += command else: gerrit_command.append(command) - return self.exec_command(" ".join(gerrit_command)) + self.lock.acquire() + stdin, stdout, stderr = self.exec_command(" ".join(gerrit_command)) + self.lock.release() + return stdin, stdout, stderr |
