Introduce scheduling opportunities into the backup thread

This commit is contained in:
Charles Haley 2010-09-26 14:06:56 +01:00
parent 12f75ddaf8
commit f6870bd14b

View File

@ -67,6 +67,11 @@ class MetadataBackup(Thread): # {{{
prints('Failed to get backup metadata for id:', id_, 'again, giving up') prints('Failed to get backup metadata for id:', id_, 'again, giving up')
traceback.print_exc() traceback.print_exc()
continue continue
# Give the GUI thread a chance to do something. Python threads don't
# have priorities, so this thread would naturally keep the processor
# until some scheduling event happens. The sleep makes such an event
time.sleep(0.010)
try: try:
print 'now do metadata' print 'now do metadata'
raw = metadata_to_opf(mi) raw = metadata_to_opf(mi)
@ -75,6 +80,7 @@ class MetadataBackup(Thread): # {{{
traceback.print_exc() traceback.print_exc()
continue continue
time.sleep(0.010) # Give the GUI thread a chance to do something
try: try:
self.do_write(path, raw) self.do_write(path, raw)
except: except:
@ -87,6 +93,7 @@ class MetadataBackup(Thread): # {{{
'again, giving up') 'again, giving up')
continue continue
time.sleep(0.010) # Give the GUI thread a chance to do something
try: try:
self.clear_dirtied([id_]) self.clear_dirtied([id_])
except: except: