Use a common lock for the KMLgen and SQL threads to keep them from stepping on each other when reading the SQLite db

This commit is contained in:
Nick Foster
2012-10-09 23:31:02 -07:00
parent d86e568ac2
commit 67b58d7204
4 changed files with 47 additions and 44 deletions
+3 -2
View File
@@ -252,11 +252,12 @@ class mainwindow(QtGui.QMainWindow):
self.outputs = [self.datamodelout.output]
self.updates = []
self.lock = threading.Lock() #grab a lock to ensure sql and kml don't step on each other
#output options to populate outputs, updates
if self.ui.check_kml.checkState():
#we spawn a thread to run every 30 seconds (or whatever) to generate KML
self.kmlgen = air_modes.output_kml(self.ui.line_kmlfilename.text(), self.dbname, my_position) #create a KML generating thread
self.kmlgen = air_modes.output_kml(self.ui.line_kmlfilename.text(), self.dbname, my_position, self.lock) #create a KML generating thread
if self.ui.check_sbs1.checkState():
sbs1port = int(self.ui.line_sbs1port.text())
@@ -281,7 +282,7 @@ class mainwindow(QtGui.QMainWindow):
self.outputs.append(self.output_live_data)
#create SQL database for KML and dashboard displays
self.dbwriter = air_modes.output_sql(my_position, self.dbname)
self.dbwriter = air_modes.output_sql(my_position, self.dbname, self.lock)
self.outputs.append(self.dbwriter.output) #now the db will update itself
#output to update reports/sec widget