take global lock while doing imports
This commit is contained in:
parent
6a69bf512e
commit
3352f608cf
|
@ -154,6 +154,12 @@ class GuiAutoImport (threading.Thread):
|
||||||
# results to the same pipe. This means that self.path should be a a list of dirs
|
# results to the same pipe. This means that self.path should be a a list of dirs
|
||||||
# to watch.
|
# to watch.
|
||||||
if widget.get_active(): # toggled on
|
if widget.get_active(): # toggled on
|
||||||
|
# - Does the lock acquisition need to be more sophisticated for multiple dirs?
|
||||||
|
# (see comment above about what to do if pipe already open)
|
||||||
|
# - Ideally we want to release the lock if the auto-import is killed by some
|
||||||
|
# kind of exception - is this possible?
|
||||||
|
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
||||||
|
print "\nGlobal lock taken ..."
|
||||||
self.doAutoImportBool = True
|
self.doAutoImportBool = True
|
||||||
widget.set_label(u' _Stop Autoimport ')
|
widget.set_label(u' _Stop Autoimport ')
|
||||||
if self.pipe_to_hud is None:
|
if self.pipe_to_hud is None:
|
||||||
|
@ -176,9 +182,12 @@ class GuiAutoImport (threading.Thread):
|
||||||
|
|
||||||
interval=int(self.intervalEntry.get_text())
|
interval=int(self.intervalEntry.get_text())
|
||||||
gobject.timeout_add(interval*1000, self.do_import)
|
gobject.timeout_add(interval*1000, self.do_import)
|
||||||
|
else:
|
||||||
|
print "auto-import aborted - global lock not available"
|
||||||
else: # toggled off
|
else: # toggled off
|
||||||
|
self.settings['global_lock'].release()
|
||||||
self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
|
self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
|
||||||
print "Stopping autoimport"
|
print "Stopping autoimport - global lock released."
|
||||||
if self.pipe_to_hud.poll() is not None:
|
if self.pipe_to_hud.poll() is not None:
|
||||||
print "HUD already terminated"
|
print "HUD already terminated"
|
||||||
else:
|
else:
|
||||||
|
@ -187,8 +196,6 @@ class GuiAutoImport (threading.Thread):
|
||||||
self.pipe_to_hud = None
|
self.pipe_to_hud = None
|
||||||
self.startButton.set_label(u' _Start Autoimport ')
|
self.startButton.set_label(u' _Start Autoimport ')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#end def GuiAutoImport.startClicked
|
#end def GuiAutoImport.startClicked
|
||||||
|
|
||||||
def get_vbox(self):
|
def get_vbox(self):
|
||||||
|
|
|
@ -49,10 +49,15 @@ class GuiBulkImport():
|
||||||
self.importer.RunImportThreaded()
|
self.importer.RunImportThreaded()
|
||||||
|
|
||||||
def load_clicked(self, widget, data=None):
|
def load_clicked(self, widget, data=None):
|
||||||
# get the dir to import from the chooser
|
# Does the lock acquisition need to be more sophisticated for multiple dirs?
|
||||||
|
# (see comment above about what to do if pipe already open)
|
||||||
|
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
||||||
|
try:
|
||||||
|
print "\nGlobal lock taken ..."
|
||||||
|
# get the dir to import from the chooser
|
||||||
self.inputFile = self.chooser.get_filename()
|
self.inputFile = self.chooser.get_filename()
|
||||||
|
|
||||||
# get the import settings from the gui and save in the importer
|
# get the import settings from the gui and save in the importer
|
||||||
self.importer.setHandCount(int(self.spin_hands.get_text()))
|
self.importer.setHandCount(int(self.spin_hands.get_text()))
|
||||||
self.importer.setMinPrint(int(self.spin_hands.get_text()))
|
self.importer.setMinPrint(int(self.spin_hands.get_text()))
|
||||||
self.importer.setQuiet(self.chk_st_st.get_active())
|
self.importer.setQuiet(self.chk_st_st.get_active())
|
||||||
|
@ -80,6 +85,11 @@ class GuiBulkImport():
|
||||||
self.importer.clearFileList()
|
self.importer.clearFileList()
|
||||||
|
|
||||||
self.lab_info.set_text("Import finished")
|
self.lab_info.set_text("Import finished")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self.settings['global_lock'].release()
|
||||||
|
else:
|
||||||
|
print "bulk-import aborted - global lock not available"
|
||||||
|
|
||||||
def get_vbox(self):
|
def get_vbox(self):
|
||||||
"""returns the vbox of this thread"""
|
"""returns the vbox of this thread"""
|
||||||
|
@ -88,8 +98,7 @@ class GuiBulkImport():
|
||||||
def __init__(self, settings, config):
|
def __init__(self, settings, config):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.config = config
|
self.config = config
|
||||||
self.importer = fpdb_import.Importer(self, self.settings,
|
self.importer = fpdb_import.Importer(self, self.settings, config)
|
||||||
config)
|
|
||||||
|
|
||||||
self.vbox = gtk.VBox(False, 0)
|
self.vbox = gtk.VBox(False, 0)
|
||||||
self.vbox.show()
|
self.vbox.show()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user