mirror of https://gitlab.com/ita1024/waf.git
Python 3 fixes
This commit is contained in:
parent
8207a878a9
commit
b2bcee43cb
|
@ -812,7 +812,8 @@ def sane_path(p):
|
|||
process_lock = threading.Lock()
|
||||
process_pool = []
|
||||
def get_process():
|
||||
with process_lock:
|
||||
try:
|
||||
process_lock.acquire()
|
||||
for proc in process_pool:
|
||||
if not proc.used:
|
||||
proc.used = True
|
||||
|
@ -821,11 +822,14 @@ def get_process():
|
|||
filepath = os.path.dirname(os.path.abspath(__file__)) + os.sep + 'processor.py'
|
||||
cmd = [sys.executable, filepath]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, bufsize=0)
|
||||
proc.stdin.write('%d\n' % os.getpid())
|
||||
header = '%d\n' % os.getpid()
|
||||
proc.stdin.write(header.encode())
|
||||
proc.stdin.flush()
|
||||
proc.used = True
|
||||
process_pool.append(proc)
|
||||
return proc
|
||||
finally:
|
||||
process_lock.release()
|
||||
|
||||
def run_process(cmd, kwargs, cargs=None, local=False):
|
||||
if local or not kwargs.get('stdout', None) or not kwargs.get('stderr', None):
|
||||
|
@ -841,7 +845,7 @@ def run_process(cmd, kwargs, cargs=None, local=False):
|
|||
proc = get_process()
|
||||
obj = cPickle.dumps([cmd, kwargs, cargs], 0)
|
||||
header = "%d\n" % len(obj)
|
||||
proc.stdin.write(header)
|
||||
proc.stdin.write(header.encode())
|
||||
proc.stdin.write(obj)
|
||||
proc.stdin.flush()
|
||||
|
||||
|
|
|
@ -25,13 +25,16 @@ def perr(msg):
|
|||
# quit if the parent process ends abruptly
|
||||
ppid = int(sys.stdin.readline())
|
||||
def reap():
|
||||
while 1:
|
||||
try:
|
||||
os.kill(ppid, 0)
|
||||
except OSError:
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
if os.sep != '/':
|
||||
os.waitpid(ppid, 0)
|
||||
else:
|
||||
while 1:
|
||||
try:
|
||||
os.kill(ppid, 0)
|
||||
except OSError:
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
os.kill(os.getpid(), signal.SIGKILL)
|
||||
t = threading.Thread(target=reap)
|
||||
t.setDaemon(True)
|
||||
|
@ -45,7 +48,7 @@ while 1:
|
|||
|
||||
buflen = int(txt.strip())
|
||||
obj = sys.stdin.read(buflen)
|
||||
[cmd, kwargs, cargs] = cPickle.loads(obj)
|
||||
[cmd, kwargs, cargs] = cPickle.loads(obj.encode())
|
||||
cargs = cargs or {}
|
||||
|
||||
ret = 1
|
||||
|
@ -69,8 +72,7 @@ while 1:
|
|||
obj = cPickle.dumps(tmp, 0)
|
||||
|
||||
header = "%d\n" % len(obj)
|
||||
|
||||
sys.stdout.write(header)
|
||||
sys.stdout.write(obj)
|
||||
sys.stdout.write(obj.decode(sys.stdout.encoding or 'iso8859-1'))
|
||||
sys.stdout.flush()
|
||||
|
||||
|
|
Loading…
Reference in New Issue