mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1280040 [[FYI] - Left overs in temp](https://bugs.launchpad.net/calibre/+bug/1280040)
This commit is contained in:
parent
6c5e9e9769
commit
3162d78fd2
@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import sys, os, importlib
|
||||
import sys, os, importlib, time
|
||||
|
||||
from PyQt4.Qt import QIcon
|
||||
|
||||
@ -67,6 +67,12 @@ def _run(args, notify=None):
|
||||
if len(args) > 1:
|
||||
main.boss.open_book(args[1], edit_file=opts.edit_file, clear_notify_data=False)
|
||||
app.exec_()
|
||||
# Ensure that the parse worker has quit so that temp files can be deleted
|
||||
# on windows
|
||||
st = time.time()
|
||||
from calibre.gui2.tweak_book.preview import parse_worker
|
||||
while parse_worker.is_alive() and time.time() - st < 120:
|
||||
time.sleep(0.1)
|
||||
|
||||
def main(args=sys.argv):
|
||||
_run(args)
|
||||
|
@ -155,6 +155,9 @@ class ParseWorker(Thread):
|
||||
def clear(self):
|
||||
self.parse_items.clear()
|
||||
|
||||
def is_alive(self):
|
||||
return Thread.is_alive(self) or self.worker.is_alive()
|
||||
|
||||
parse_worker = ParseWorker()
|
||||
# }}}
|
||||
|
||||
|
@ -58,6 +58,8 @@ class OffloadWorker(object):
|
||||
self.listener = listener
|
||||
self.worker = worker
|
||||
self.conn = None
|
||||
self.kill_thread = t = Thread(target=self.worker.kill)
|
||||
t.daemon = True
|
||||
|
||||
def __call__(self, module, func, *args, **kwargs):
|
||||
if self.conn is None:
|
||||
@ -73,13 +75,14 @@ class OffloadWorker(object):
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
self.conn = None
|
||||
t = Thread(target=self.worker.kill)
|
||||
t.daemon = True
|
||||
try:
|
||||
os.remove(self.worker.log_path)
|
||||
except:
|
||||
pass
|
||||
t.start()
|
||||
self.kill_thread.start()
|
||||
|
||||
def is_alive(self):
|
||||
return self.worker.is_alive or self.kill_thread.is_alive()
|
||||
|
||||
def communicate(ans, worker, listener, args, timeout=300, heartbeat=None,
|
||||
abort=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user