fix modules and 2.6 compatibility
diff --git a/wally/utils.py b/wally/utils.py
index d94d333..f5ab8b6 100644
--- a/wally/utils.py
+++ b/wally/utils.py
@@ -1,14 +1,17 @@
import re
import os
import sys
-import time
-import psutil
import socket
import logging
import threading
import contextlib
import subprocess
+try:
+ import psutil
+except ImportError:
+ psutil = None
+
logger = logging.getLogger("wally")
@@ -191,11 +194,14 @@
thread.join(timeout)
if thread.is_alive():
+ if psutil is not None:
+ parent = psutil.Process(proc.pid)
+ for child in parent.children(recursive=True):
+ child.kill()
+ parent.kill()
+ else:
+ proc.kill()
- parent = psutil.Process(proc.pid)
- for child in parent.children(recursive=True):
- child.kill()
- parent.kill()
thread.join()
raise RuntimeError("Local process timeout: " + str(cmd))