This commit is contained in:
Kovid Goyal 2025-05-24 13:12:43 +05:30
parent 7efc361602
commit cd93465871
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 11 deletions

View File

@ -75,6 +75,14 @@ def headless_exe_path(exe_name='calibre-parallel'):
return exe_path(exe_name)
def windows_creationflags_for_worker_process(priority: str = 'normal') -> int:
return {
'high' : subprocess.HIGH_PRIORITY_CLASS,
'normal': subprocess.NORMAL_PRIORITY_CLASS,
'low' : subprocess.IDLE_PRIORITY_CLASS
}[priority] | subprocess.CREATE_NO_WINDOW
class Worker:
'''
Platform independent object for launching child processes. All processes
@ -182,11 +190,7 @@ class Worker:
'cwd': _cwd,
}
if iswindows:
priority = {
'high' : subprocess.HIGH_PRIORITY_CLASS,
'normal': subprocess.NORMAL_PRIORITY_CLASS,
'low' : subprocess.IDLE_PRIORITY_CLASS}[priority]
args['creationflags'] = subprocess.CREATE_NO_WINDOW|priority
args['creationflags'] = windows_creationflags_for_worker_process(priority)
else:
niceness = {
'normal': 0,

View File

@ -14,7 +14,7 @@ from threading import Thread
from calibre.constants import iswindows
from calibre.utils.ipc import eintr_retry_call
from calibre.utils.ipc.launch import Worker
from calibre.utils.ipc.launch import Worker, windows_creationflags_for_worker_process
from calibre.utils.monotonic import monotonic
from polyglot.builtins import environ_item, string_or_bytes
@ -142,11 +142,7 @@ def start_pipe_worker(command, env=None, priority='normal', **process_args):
pass_fds = None
try:
if iswindows:
priority = {
'high' : subprocess.HIGH_PRIORITY_CLASS,
'normal': subprocess.NORMAL_PRIORITY_CLASS,
'low' : subprocess.IDLE_PRIORITY_CLASS}[priority]
args['creationflags'] = subprocess.CREATE_NO_WINDOW|priority
args['creationflags'] = windows_creationflags_for_worker_process(priority)
pass_fds = args.pop('pass_fds', None)
if pass_fds:
for fd in pass_fds: