remote: manually close all ssh pools at the end

Python 2 fails to do it automatically occasionally and shows weird error
messages.

This was harmless but confusing.
This commit is contained in:
Alexander Schepanovski
2019-07-17 22:20:43 +07:00
parent 7d3e9808b5
commit 6010ce54cd
2 changed files with 10 additions and 0 deletions
+4
View File
@@ -8,6 +8,7 @@ from dvc.cli import parse_args
from dvc.config import ConfigError
from dvc.analytics import Analytics
from dvc.exceptions import NotDvcRepoError, DvcParserError
from dvc.remote.ssh.pool import close_ssh_pools
logger = logging.getLogger("dvc")
@@ -53,6 +54,9 @@ def main(argv=None):
ret = 255
finally:
logger.setLevel(outerLogLevel)
# Python 2 fails to close these clean occasionally and users see
# weird error messages, so we do it manually
close_ssh_pools()
Analytics().send_cmd(cmd, args, ret)
+6
View File
@@ -22,6 +22,12 @@ def get_ssh_pool(*conn_args, **conn_kwargs):
return SSHPool(conn_args, conn_kwargs)
def close_ssh_pools():
for pool in get_ssh_pool.memory.values():
pool.close()
get_ssh_pool.memory.clear()
class SSHPool(object):
def __init__(self, conn_args, conn_kwargs):
self._conn_args = conn_args