Pass through event loop
[osm/N2VC.git] / juju / utils.py
index 78322e7..c0a500c 100644 (file)
@@ -1,10 +1,9 @@
 import asyncio
-import concurrent.futures
 import os
 from pathlib import Path
 
 
-async def execute_process(*cmd, log=None):
+async def execute_process(*cmd, log=None, loop=None):
     '''
     Wrapper around asyncio.create_subprocess_exec.
 
@@ -14,7 +13,7 @@ async def execute_process(*cmd, log=None):
             stdin=asyncio.subprocess.PIPE,
             stdout=asyncio.subprocess.PIPE,
             stderr=asyncio.subprocess.PIPE,
-            )
+            loop=loop)
     stdout, stderr = await p.communicate()
     if log:
         log.debug("Exec %s -> %d", cmd, p.returncode)
@@ -45,8 +44,4 @@ async def read_ssh_key(loop):
     can be passed on to a model.
 
     '''
-    ssh_key = await loop.run_in_executor(
-        concurrent.futures.ThreadPoolExecutor(),
-        _read_ssh_key
-    )
-    return ssh_key
+    return await loop.run_in_executor(None, _read_ssh_key)