Moved execution of utils.read_ssh_key to a thread.
authorPete Vander Giessen <petevg@gmail.com>
Fri, 27 Jan 2017 23:00:35 +0000 (18:00 -0500)
committerPete Vander Giessen <petevg@gmail.com>
Fri, 27 Jan 2017 23:12:47 +0000 (18:12 -0500)
It's a blocking operation, so into a thread it goes!

juju/controller.py

index e3234f8..d64a2f7 100644 (file)
@@ -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 <key>` in the cli "