Remove pre-included windows portaudio static libs
[jack2.git] / waflib / processor.py
blob2eecf3bd93f43431a13163b75f814d220beed120
1 #! /usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2016-2018 (ita)
5 import os, sys, traceback, base64, signal
6 try:
7 import cPickle
8 except ImportError:
9 import pickle as cPickle
11 try:
12 import subprocess32 as subprocess
13 except ImportError:
14 import subprocess
16 try:
17 TimeoutExpired = subprocess.TimeoutExpired
18 except AttributeError:
19 class TimeoutExpired(Exception):
20 pass
22 def run():
23 txt = sys.stdin.readline().strip()
24 if not txt:
25 # parent process probably ended
26 sys.exit(1)
27 [cmd, kwargs, cargs] = cPickle.loads(base64.b64decode(txt))
28 cargs = cargs or {}
30 ret = 1
31 out, err, ex, trace = (None, None, None, None)
32 try:
33 proc = subprocess.Popen(cmd, **kwargs)
34 try:
35 out, err = proc.communicate(**cargs)
36 except TimeoutExpired:
37 if kwargs.get('start_new_session') and hasattr(os, 'killpg'):
38 os.killpg(proc.pid, signal.SIGKILL)
39 else:
40 proc.kill()
41 out, err = proc.communicate()
42 exc = TimeoutExpired(proc.args, timeout=cargs['timeout'], output=out)
43 exc.stderr = err
44 raise exc
45 ret = proc.returncode
46 except Exception as e:
47 exc_type, exc_value, tb = sys.exc_info()
48 exc_lines = traceback.format_exception(exc_type, exc_value, tb)
49 trace = str(cmd) + '\n' + ''.join(exc_lines)
50 ex = e.__class__.__name__
52 # it is just text so maybe we do not need to pickle()
53 tmp = [ret, out, err, ex, trace]
54 obj = base64.b64encode(cPickle.dumps(tmp))
55 sys.stdout.write(obj.decode())
56 sys.stdout.write('\n')
57 sys.stdout.flush()
59 while 1:
60 try:
61 run()
62 except KeyboardInterrupt:
63 break