mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix cleanup of device jobs on device yank
This commit is contained in:
parent
c0fbc32e4c
commit
cdbfc91eff
@ -37,6 +37,7 @@ class DeviceJob(BaseJob):
|
||||
self.exception = None
|
||||
self.job_manager = job_manager
|
||||
self._details = _('No details available.')
|
||||
self._aborted = False
|
||||
|
||||
def start_work(self):
|
||||
self.start_time = time.time()
|
||||
@ -55,7 +56,11 @@ class DeviceJob(BaseJob):
|
||||
self.start_work()
|
||||
try:
|
||||
self.result = self.func(*self.args, **self.kwargs)
|
||||
if self._aborted:
|
||||
return
|
||||
except (Exception, SystemExit), err:
|
||||
if self._aborted:
|
||||
return
|
||||
self.failed = True
|
||||
self._details = unicode(err) + '\n\n' + \
|
||||
traceback.format_exc()
|
||||
@ -63,6 +68,12 @@ class DeviceJob(BaseJob):
|
||||
finally:
|
||||
self.job_done()
|
||||
|
||||
def abort(self, err):
|
||||
self._aborted = True
|
||||
self.failed = True
|
||||
self._details = unicode(err)
|
||||
self.exception = err
|
||||
|
||||
@property
|
||||
def log_file(self):
|
||||
return cStringIO.StringIO(self._details.encode('utf-8'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user