diff --git a/src/calibre/utils/ipc/launch.py b/src/calibre/utils/ipc/launch.py index 4f5a546729..28cdeb4df8 100644 --- a/src/calibre/utils/ipc/launch.py +++ b/src/calibre/utils/ipc/launch.py @@ -16,7 +16,7 @@ from calibre.ptempfile import PersistentTemporaryFile, base_dir if iswindows: import win32process try: - _windows_null_file = open(os.devnull, 'wb') + windows_null_file = open(os.devnull, 'wb') except: raise RuntimeError('NUL file missing in windows. This indicates a' ' corrupted windows. You should contact Microsoft' @@ -212,7 +212,7 @@ class Worker(object): # On windows when using the pythonw interpreter, # stdout, stderr and stdin may not be valid args['stdin'] = subprocess.PIPE - args['stdout'] = _windows_null_file + args['stdout'] = windows_null_file args['stderr'] = subprocess.STDOUT if not iswindows: diff --git a/src/calibre/utils/ipc/pool.py b/src/calibre/utils/ipc/pool.py index 794c8f582c..fa1ac16e73 100644 --- a/src/calibre/utils/ipc/pool.py +++ b/src/calibre/utils/ipc/pool.py @@ -12,6 +12,7 @@ from collections import namedtuple from Queue import Queue from calibre import detect_ncpus, as_unicode, prints +from calibre.constants import iswindows from calibre.ptempfile import PersistentTemporaryFile from calibre.utils import join_with_timeout from calibre.utils.ipc import eintr_retry_call @@ -24,6 +25,11 @@ File = namedtuple('File', 'name') MAX_SIZE = 30 * 1024 * 1024 # max size of data to send over the connection (old versions of windows cannot handle arbitrary data lengths) +worker_kwargs = {'stdout':None} +if iswindows and getattr(sys, 'gui_app', False): + from calibre.utils.ipc.launch import windows_null_file + worker_kwargs['stdout'] = worker_kwargs['stderr'] = windows_null_file + class Failure(Exception): def __init__(self, tf): @@ -132,7 +138,7 @@ class Pool(Thread): def create_worker(self): from calibre.utils.ipc.simple_worker import start_pipe_worker p = start_pipe_worker( - 'from {0} import run_main, {1}; run_main({1})'.format(self.__class__.__module__, 'worker_main'), stdout=None) + 'from {0} import run_main, {1}; run_main({1})'.format(self.__class__.__module__, 'worker_main'), **worker_kwargs) sys.stdout.flush() eintr_retry_call(p.stdin.write, self.worker_data) p.stdin.flush(), p.stdin.close()