mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Pull from trunk
This commit is contained in:
commit
676fc555a7
@ -18,6 +18,7 @@ from calibre.utils.ipc.launch import Worker
|
|||||||
from calibre.utils.ipc.worker import PARALLEL_FUNCS
|
from calibre.utils.ipc.worker import PARALLEL_FUNCS
|
||||||
from calibre import detect_ncpus as cpu_count
|
from calibre import detect_ncpus as cpu_count
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
|
from calibre.ptempfile import base_dir
|
||||||
|
|
||||||
_counter = 0
|
_counter = 0
|
||||||
|
|
||||||
@ -114,8 +115,9 @@ class Server(Thread):
|
|||||||
with self._worker_launch_lock:
|
with self._worker_launch_lock:
|
||||||
self.launched_worker_count += 1
|
self.launched_worker_count += 1
|
||||||
id = self.launched_worker_count
|
id = self.launched_worker_count
|
||||||
rfile = os.path.join(tempfile.gettempdir(),
|
fd, rfile = tempfile.mkstemp(prefix='ipc_result_%d_%d_'%(self.id, id),
|
||||||
'calibre_ipc_result_%d_%d.pickle'%(self.id, id))
|
dir=base_dir(), suffix='.pickle')
|
||||||
|
os.close(fd)
|
||||||
if redirect_output is None:
|
if redirect_output is None:
|
||||||
redirect_output = not gui
|
redirect_output = not gui
|
||||||
|
|
||||||
@ -189,8 +191,12 @@ class Server(Thread):
|
|||||||
job.failed = True
|
job.failed = True
|
||||||
job.returncode = worker.returncode
|
job.returncode = worker.returncode
|
||||||
elif os.path.exists(worker.rfile):
|
elif os.path.exists(worker.rfile):
|
||||||
|
try:
|
||||||
job.result = cPickle.load(open(worker.rfile, 'rb'))
|
job.result = cPickle.load(open(worker.rfile, 'rb'))
|
||||||
os.remove(worker.rfile)
|
os.remove(worker.rfile)
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
job.duration = time.time() - job.start_time
|
job.duration = time.time() - job.start_time
|
||||||
self.changed_jobs_queue.put(job)
|
self.changed_jobs_queue.put(job)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user