From: Pete Vander Giessen Date: Fri, 27 Jan 2017 23:00:35 +0000 (-0500) Subject: Moved execution of utils.read_ssh_key to a thread. X-Git-Tag: 0.2.0~1^2~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=cdaa13be828af9cae8ec42818fc2f4353c4f20c2;p=osm%2FN2VC.git Moved execution of utils.read_ssh_key to a thread. It's a blocking operation, so into a thread it goes! --- diff --git a/juju/controller.py b/juju/controller.py index e3234f8..d64a2f7 100644 --- a/juju/controller.py +++ b/juju/controller.py @@ -1,4 +1,5 @@ import asyncio +import concurrent.futures import logging from . import tag @@ -102,11 +103,14 @@ class Controller(object): # Add our ssh key to the model, to work around # https://bugs.launchpad.net/juju/+bug/1643076 try: - ssh_key = utils.read_ssh_key() + ssh_key = await self.loop.run_in_executor( + concurrent.futures.ThreadPoolExecutor(), + utils.read_ssh_key + ) await utils.execute_process( 'juju', 'add-ssh-key', '-m', model_name, ssh_key, log=log) except Exception as e: - log.warning( + log.exception( "Could not add ssh key to model. You will not be able " "to ssh into machines in this model. " "Manually running `juju add-ssh-key ` in the cli "