Fix issue with newer popen and threading
Define exception