From 91227347dd7912d3e15a1026e9db4d0a993f4ada Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Mar 2008 19:55:48 +0000 Subject: [PATCH] Fix multi-processing code to work with py2exe'd executables --- src/libprs500/parallel.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libprs500/parallel.py b/src/libprs500/parallel.py index 81ba88155f..f349ee09d3 100644 --- a/src/libprs500/parallel.py +++ b/src/libprs500/parallel.py @@ -33,11 +33,14 @@ PARALLEL_FUNCS = { } python = sys.executable +popen = subprocess.Popen + if iswindows: if hasattr(sys, 'frozen'): python = os.path.join(os.path.dirname(python), 'parallel.exe') else: python = os.path.join(os.path.dirname(python), 'Scripts\\parallel.exe') + popen = partial(subprocess.Popen, creationflags=0x08) # CREATE_NO_WINDOW=0x08 so that no ugly console is popped up def cleanup(tdir): try: @@ -109,11 +112,13 @@ class Server(object): cmd = prefix + 'from libprs500.parallel import run_job; run_job(\'%s\')'%binascii.hexlify(job_data) if not monitor: - subprocess.Popen([python, '-c', cmd]) + popen([python, '-c', cmd]) return output = open(os.path.join(job_dir, 'output.txt'), 'wb') - p = subprocess.Popen([python, '-c', cmd], stdout=output, stderr=output) + p = popen([python, '-c', cmd], stdout=output, stderr=output, + stdin=subprocess.PIPE) + p.stdin.close() while p.returncode is None: if job_id in self.kill_jobs: self._terminate(p)