InvokeLater varying Client Experience

I have a script containing several functions that perform database updates and then call another function (custom method on root container) to set the State of all the components on the screen (mainly property bindings to update the user that the changes were committed and in fact updated on the backend). These updates need to be performed synchronously since there are intermediary calculations from the 1st database update that are used in the next database update and so on. So I have been using system.util.invokeLater with a 5 second delay to all enough time for the database to update before running the setState function and continuing with subsequent update queries.

So my question is the delay time in reference to the client session? On my PC, internet/vpn connection, the components update correctly. But for some other clients, they don’t see the updates. It’s like the 5 second delay isn’t long enough to update the the database and the components for that specific client. So is this a function of each client’s PC and connection? I don’t want to keep increasing the delay just to accommodate certain ‘slow’ clients.

Is their another way where I can ensure a promise (think Javascript) is resolved before setting the State of all the components to reflect the updates (i.e. eliminating the need for an arbitrary delay value)?

def setState():
	#set state of all components
	event.source.parent.parent.parent.parent.setState()
	return
	
def updateRM():
	#------UPDATE BSRawMaterial table----------------------------------
	SolidMass=event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('SolidKg').floatValue
	BatchSizeKg=event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('BatchSizeKg').floatValue
	
	RawMaterialTable = event.source.parent.getComponent('ContainerRawMaterial').getComponent('PTRawMaterial')
	rowcount = RawMaterialTable.data.rowCount
	
	if BatchSizeKg <= 600:
		precision = 4
	else:
		precision = 2

	if rowcount > 0:
		for row in range(rowcount):
			BSRawMaterialID = RawMaterialTable.data.getValueAt(row,'BSRawMaterialID')
			RawMaterialTypeID=RawMaterialTable.data.getValueAt(row,'RawMaterialTypeID')
			BSRawMaterialPorcent=RawMaterialTable.data.getValueAt(row,'BSRawMaterialPorcent')
			BSRawMaterialMoisture=RawMaterialTable.data.getValueAt(row,'BSRawMaterialMoisture')
			BSRawMaterialSSD=RawMaterialTable.data.getValueAt(row,'BSRawMaterialSSD')
			BSRawMaterialDensity=RawMaterialTable.data.getValueAt(row,'BSRawMaterialDensity')
			BSRawMaterialKg=RawMaterialTable.data.getValueAt(row,'BSRawMaterialKg')
			
			#Calculated Fields
			BSRawMaterialKg = round(((BSRawMaterialPorcent/100)*SolidMass) / \
								 (1-(BSRawMaterialMoisture-BSRawMaterialSSD)/100),precision)
								 
			#if RawMaterialTypeID == 0:
				#event.source.parent.CementKg = BSRawMaterialKg
				
			BSRawMaterialLiquidKg = round(BSRawMaterialMoisture*BSRawMaterialKg/100,4)				
			
			if BSRawMaterialDensity > 0:							
				BSRawMaterialVolume = round(BSRawMaterialKg/BSRawMaterialDensity,4)
										
			BSRawMaterialWaterContent = round(BSRawMaterialMoisture*BSRawMaterialVolume/100,4)
			
			#Update Query
			querylist=[BSRawMaterialKg,BSRawMaterialLiquidKg,BSRawMaterialVolume,BSRawMaterialID]
			query='''UPDATE BSRawMaterial SET 
					BSRawMaterialKg=?,BSRawMaterialLiquidKg=?,BSRawMaterialVolume=?
					WHERE BSRawMaterialID=?'''
			print querylist
			system.db.runPrepUpdate(query, querylist)
			system.db.refresh(event.source.parent.getComponent('ContainerRawMaterial').getComponent('PTRawMaterial'), 'data')
			
	print 'Raw Materials Updated'
	system.util.invokeLater(setState, 5000) #set state of components in 5 seconds
	system.util.invokeLater(updateBinder, 5000) #update binder table in 5 seconds
	system.util.invokeLater(updateAdmix, 5000)	#update admix table in 5 seconds
	#system.util.invokeAsynchronous(updateBinder)
	#system.util.invokeAsynchronous(updateAdmix)
	return 
	
def updateBinder():
	CementKg = event.source.parent.CementKg
	BatchSizeKg=event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('BatchSizeKg').floatValue
		
	BinderTable = event.source.parent.getComponent('ContainerBinder').getComponent('PTBinder')
	rowcount = BinderTable.data.rowCount

	if BatchSizeKg <= 600:
		precision = 4
	else:
		precision = 2
		
	if rowcount > 0:		
		for row in range(rowcount):
			BSBinderID=BinderTable.data.getValueAt(row,'BSBinderID')
			BSBinderMassPorcent=BinderTable.data.getValueAt(row,'BSBinderMassPorcent')
			
			#Calculation
			BSBinderMassKg =round(CementKg * BSBinderMassPorcent/100,precision)
			
			#Update query
			querylist=[BSBinderMassKg,BSBinderID]
			query='UPDATE BSBinder SET BSBinderMassKg=? WHERE BSBinderID=?'
			print querylist
			system.db.runPrepUpdate(query, querylist)
			system.db.refresh(event.source.parent.getComponent('ContainerBinder').getComponent('PTBinder'), 'data')
			
	print 'Binders Updated'
	return

def updateAdmix():
	CementKg = event.source.parent.CementKg
	
	AdmixTable = event.source.parent.getComponent('ContainerAdmixture').getComponent('PTAdmixture')
	rowcount = AdmixTable.data.rowCount

	if rowcount > 0:
		for row in range(rowcount):
			BSAdmixtureID=AdmixTable.data.getValueAt(row,'BSAdmixtureID')
			BSAdmixtureSG=AdmixTable.data.getValueAt(row,'BSAdmixtureSG')
			BSAdmixtureDosage=AdmixTable.data.getValueAt(row,'BSAdmixtureDosage')
			
			#Calculation
			BSAdmixtureMassG=round(CementKg * BSAdmixtureSG * BSAdmixtureDosage,2)
			
			#Update query
			querylist=[BSAdmixtureMassG,BSAdmixtureID]
			query='UPDATE BSAdmixture SET BSAdmixtureMassG=? WHERE BSAdmixtureID=?'
			print querylist
			system.db.runPrepUpdate(query, querylist)
			system.db.refresh(event.source.parent.getComponent('ContainerAdmixture').getComponent('PTAdmixture'), 'data')
		
	print 'Admixtures Updated'
	
	#Enable Buttons
	event.source.parent.cursorCode = 0 #reset cursor to default
	event.source.parent.getComponent('Button 4').componentEnabled = 1
	event.source.componentEnabled = 1	
	return
	
def updateWater():
	BatchSheetID=event.source.parent.getComponent('ContainerGeneral').getComponent('DropdownBatchSheet').selectedValue
	CementKg = event.source.parent.CementKg
	LiquidKg = event.source.parent.LiquidKg
	TotalWaterContent = event.source.parent.TotalWaterContent
	print TotalWaterContent
	
	#Calculation
	BatchAdjustedWater = round(LiquidKg - TotalWaterContent, 4)
	BatchWC = round(LiquidKg / CementKg, 4)

	#Update query
	querylist=[BatchAdjustedWater,BatchWC,BatchSheetID]
	query='UPDATE BatchSheetGeneral SET BatchAdjustedWater=?,BatchWC=? WHERE BatchSheetID=?'
	print querylist
	system.db.runPrepUpdate(query, querylist)
	#event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerLiquid').getComponent('AjustWater').floatValue=BatchAdjustedWater
	#event.source.parent.getComponent('ContainerGeneral').getComponent('wc').floatValue=BatchWC
	
	system.util.invokeLater(setState, 10000) #set the state in 10 seconds
	print 'Water Updated'
	return

#Disable Buttons
event.source.parent.cursorCode = 3 #show updating cursor
event.source.parent.getComponent('Button 4').componentEnabled = 0
event.source.componentEnabled = 0
		
#------UPDATE BatchSheetGeneral table----------------------------------
BatchSheetDate=event.source.parent.getComponent('ContainerGeneral').getComponent('Popup Calendar').date
MoldID=event.source.parent.getComponent('ContainerGeneral').getComponent('MoldType').selectedValue
ChildFaceMixID=event.source.parent.getComponent('ContainerGeneral').NewFaceMixID
SampleBoard=event.source.parent.getComponent('ContainerGeneral').getComponent('SampleBoard').intValue
SampleVolume=round(event.source.parent.getComponent('ContainerGeneral').getComponent('SampleVolume').floatValue,8)
CreatedBy=event.source.parent.getComponent('ContainerGeneral').getComponent('CreatedBy').text
ExcecutedBy=event.source.parent.getComponent('ContainerGeneral').getComponent('ExcecutedBy').text
BatchObjective=event.source.parent.getComponent('ContainerGeneral').getComponent('Objective').text
BatchSheetSpecialNote=event.source.parent.getComponent('ContainerGeneral').getComponent('BSSpecialNotes').text
VBUFID=event.source.parent.getComponent('ContainerGeneral').getComponent('VBUF').selectedValue
ProductTypeID=event.source.parent.getComponent('ContainerGeneral').getComponent('ProductType').selectedValue
UseTypeID=event.source.parent.getComponent('ContainerGeneral').getComponent('UseType').selectedValue
ProductColorID=event.source.parent.getComponent('ContainerGeneral').getComponent('Color').selectedValue
BatchSizeKg=round(event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('BatchSizeKg').floatValue,2)
BatchSolidPorcent=round(event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('SolidPorcent').floatValue,2)
BatchSolidMassKg=round(BatchSizeKg * BatchSolidPorcent/100,2)
BatchLiquidKg=round(BatchSizeKg - BatchSolidMassKg,2)
BatchLiquidPorcent=round(100 - BatchSolidPorcent,2)
WaterDensity=round(event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerLiquid').getComponent('WaterDensity').floatValue,2)
WaterVolume=round(BatchLiquidKg / WaterDensity,4)
BatchWC=event.source.parent.getComponent('ContainerGeneral').getComponent('wc').floatValue
BatchSheetID=event.source.parent.getComponent('ContainerGeneral').getComponent('DropdownBatchSheet').selectedValue

if UseTypeID == 2 or UseTypeID != 2 and MoldID > 0: #ensure mold type is selected for throughbody and base mixes
	querylist = [BatchSheetDate,MoldID,ChildFaceMixID,
				SampleBoard,SampleVolume,CreatedBy,
				ExcecutedBy,BatchObjective,BatchSheetSpecialNote,
				VBUFID,ProductTypeID,UseTypeID,ProductColorID,
				BatchSizeKg,BatchSolidPorcent,BatchSolidMassKg,
				BatchLiquidKg,BatchLiquidPorcent,WaterDensity,
				WaterVolume,BatchWC,
				BatchSheetID]
		
	query = """UPDATE BatchSheetGeneral SET BatchSheetDate = ?,MoldID=?,ChildFaceMixID=?,
				SampleBoard=?,SampleVolume=?,CreatedBy=?,
				ExcecutedBy=?,BatchObjective=?,BatchSheetSpecialNote=?,
				VBUFID=?,ProductTypeID=?,UseTypeID=?,ProductColorID=?,
				BatchSizeKg=?,BatchSolidPorcent=?,BatchSolidMassKg=?,
				BatchLiquidKg=?,BatchLiquidPorcent=?,WaterDensity=?,
				WaterVolume=?,BatchWC=?
				WHERE BatchSheetID=?"""
					
	system.db.runPrepUpdate(query, querylist)
	
	#Refresh Components
	comp_list = ['BSGeneralState','CementKg','LiquidKg',
				'TheorDensity','TotalMass','TotalMassPercent',
				'TotalMoisture','TotalRawMaterialVolume',
				'TotalWaterContent']
	[system.db.refresh(event.source.parent, c) for c in comp_list]
	
	system.util.invokeLater(setState, 5000) #set state of all components on screen in 5 seconds
	system.util.invokeLater(updateWater, 5000) #update water fields in batchsheetgeneral table in 5 seconds
	system.util.invokeLater(updateRM, 5000) #update raw material table in 5 seconds
else:
	system.gui.messageBox('Mold not selected. Cannot save changes')

Fixed time delays are a terrible solution for varying operational delays. Try something like the techniques from this topic:

Promises are roughly equivalent to Java’s “CompletableFuture”.

1 Like

Thanks @pturmel. I’ve been messing around with these functions for a little while and not sure when to use shared.later.invokeLater vs shared.later.callLater and also where to call these functions in the main script or within the functions. Issue I’m having is no consitency in the components updating on the GUI after button click.

Basically looking to do the following synchronously:

  1. Database table update 1
  • Refresh GUI components
  • Reassign GUI component properties
  1. Database table update 2
  • Refresh GUI components
  • Reassign GUI component properties
  1. Database table update 3
  • Refresh GUI components
  • Reassign GUI component properties
  1. Database table update 4
  • Refresh GUI components
  • Reassign GUI component properties
  1. Database table update 5
  • Refresh GUI components
  • Reassign GUI component properties

I modified the code below which is all contained in the actionPerformed event handler on a ‘Save Changes’ button on the screen.

def setState():
	#set state of all components
	event.source.parent.parent.parent.parent.setState()
	return
	
def refreshComps():
	#Refresh all Components
	comp_list = ['BSGeneralState','CementKg','LiquidKg',
				'TheorDensity','TotalMass','TotalMassPercent',
				'TotalMoisture','TotalRawMaterialVolume',
				'TotalWaterContent']
	[system.db.refresh(event.source.parent, c) for c in comp_list]
	
	system.db.refresh(event.source.parent.getComponent('ContainerRawMaterial').getComponent('PTRawMaterial'), 'data')
	system.db.refresh(event.source.parent.getComponent('ContainerBinder').getComponent('PTBinder'), 'data')
	system.db.refresh(event.source.parent.getComponent('ContainerAdmixture').getComponent('PTAdmixture'), 'data')
	return
	
def updateRM():
	#------UPDATE BSRawMaterial table----------------------------------
	SolidMass=event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('SolidKg').floatValue
	BatchSizeKg=event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('BatchSizeKg').floatValue
	
	RawMaterialTable = event.source.parent.getComponent('ContainerRawMaterial').getComponent('PTRawMaterial')
	rowcount = RawMaterialTable.data.rowCount
	
	if BatchSizeKg <= 600:
		precision = 4
	else:
		precision = 2

	if rowcount > 0:
		for row in range(rowcount):
			BSRawMaterialID = RawMaterialTable.data.getValueAt(row,'BSRawMaterialID')
			RawMaterialTypeID=RawMaterialTable.data.getValueAt(row,'RawMaterialTypeID')
			BSRawMaterialPorcent=RawMaterialTable.data.getValueAt(row,'BSRawMaterialPorcent')
			BSRawMaterialMoisture=RawMaterialTable.data.getValueAt(row,'BSRawMaterialMoisture')
			BSRawMaterialSSD=RawMaterialTable.data.getValueAt(row,'BSRawMaterialSSD')
			BSRawMaterialDensity=RawMaterialTable.data.getValueAt(row,'BSRawMaterialDensity')
			BSRawMaterialKg=RawMaterialTable.data.getValueAt(row,'BSRawMaterialKg')
			
			#Calculated Fields
			BSRawMaterialKg = round(((BSRawMaterialPorcent/100)*SolidMass) / \
								 (1-(BSRawMaterialMoisture-BSRawMaterialSSD)/100),precision)
								 
			#if RawMaterialTypeID == 0:
				#event.source.parent.CementKg = BSRawMaterialKg
				
			BSRawMaterialLiquidKg = round(BSRawMaterialMoisture*BSRawMaterialKg/100,4)				
			
			if BSRawMaterialDensity > 0:							
				BSRawMaterialVolume = round(BSRawMaterialKg/BSRawMaterialDensity,4)
										
			BSRawMaterialWaterContent = round(BSRawMaterialMoisture*BSRawMaterialVolume/100,4)
			
			#Update Query
			querylist=[BSRawMaterialKg,BSRawMaterialLiquidKg,BSRawMaterialVolume,BSRawMaterialID]
			query='''UPDATE BSRawMaterial SET 
					BSRawMaterialKg=?,BSRawMaterialLiquidKg=?,BSRawMaterialVolume=?
					WHERE BSRawMaterialID=?'''
			print querylist
			system.db.runPrepUpdate(query, querylist)
	
	shared.later.invokeLater(refreshComps)
	shared.later.invokeLater(setState)	
	print 'Raw Materials Updated'
	#system.util.invokeLater(setState, 5000) #set state of components in 5 seconds
	#system.util.invokeLater(updateBinder, 5000) #update binder table in 5 seconds
	#system.util.invokeLater(updateAdmix, 5000)	#update admix table in 5 seconds
	#system.util.invokeAsynchronous(updateBinder)
	#system.util.invokeAsynchronous(updateAdmix)
	return 
	
def updateBinder():
	CementKg = event.source.parent.CementKg
	BatchSizeKg=event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('BatchSizeKg').floatValue
		
	BinderTable = event.source.parent.getComponent('ContainerBinder').getComponent('PTBinder')
	rowcount = BinderTable.data.rowCount

	if BatchSizeKg <= 600:
		precision = 4
	else:
		precision = 2
		
	if rowcount > 0:		
		for row in range(rowcount):
			BSBinderID=BinderTable.data.getValueAt(row,'BSBinderID')
			BSBinderMassPorcent=BinderTable.data.getValueAt(row,'BSBinderMassPorcent')
			
			#Calculation
			BSBinderMassKg =round(CementKg * BSBinderMassPorcent/100,precision)
			
			#Update query
			querylist=[BSBinderMassKg,BSBinderID]
			query='UPDATE BSBinder SET BSBinderMassKg=? WHERE BSBinderID=?'
			print querylist
			system.db.runPrepUpdate(query, querylist)
	
	shared.later.invokeLater(refreshComps)
	shared.later.invokeLater(setState)		
	print 'Binders Updated'
	return

def updateAdmix():
	CementKg = event.source.parent.CementKg
	
	AdmixTable = event.source.parent.getComponent('ContainerAdmixture').getComponent('PTAdmixture')
	rowcount = AdmixTable.data.rowCount

	if rowcount > 0:
		for row in range(rowcount):
			BSAdmixtureID=AdmixTable.data.getValueAt(row,'BSAdmixtureID')
			BSAdmixtureSG=AdmixTable.data.getValueAt(row,'BSAdmixtureSG')
			BSAdmixtureDosage=AdmixTable.data.getValueAt(row,'BSAdmixtureDosage')
			
			#Calculation
			BSAdmixtureMassG=round(CementKg * BSAdmixtureSG * BSAdmixtureDosage,2)
			
			#Update query
			querylist=[BSAdmixtureMassG,BSAdmixtureID]
			query='UPDATE BSAdmixture SET BSAdmixtureMassG=? WHERE BSAdmixtureID=?'
			print querylist
			system.db.runPrepUpdate(query, querylist)
	shared.later.invokeLater(refreshComps)
	shared.later.invokeLater(setState)
	print 'Admixtures Updated'
	
	#Enable Buttons
	event.source.parent.cursorCode = 0 #reset cursor to default
	event.source.parent.getComponent('Button 4').componentEnabled = 1
	event.source.componentEnabled = 1	
	return
	
def updateWater():
	BatchSheetID=event.source.parent.getComponent('ContainerGeneral').getComponent('DropdownBatchSheet').selectedValue
	CementKg = event.source.parent.CementKg
	LiquidKg = event.source.parent.LiquidKg
	TotalWaterContent = event.source.parent.TotalWaterContent
	print TotalWaterContent
	
	#Calculation
	BatchAdjustedWater = round(LiquidKg - TotalWaterContent, 4)
	BatchWC = round(LiquidKg / CementKg, 4)

	#Update query
	querylist=[BatchAdjustedWater,BatchWC,BatchSheetID]
	query='UPDATE BatchSheetGeneral SET BatchAdjustedWater=?,BatchWC=? WHERE BatchSheetID=?'
	print querylist
	system.db.runPrepUpdate(query, querylist)
	#event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerLiquid').getComponent('AjustWater').floatValue=BatchAdjustedWater
	#event.source.parent.getComponent('ContainerGeneral').getComponent('wc').floatValue=BatchWC
	
	#system.util.invokeLater(setState, 10000) #set the state in 10 seconds
	shared.later.invokeLater(refreshComps)
	shared.later.invokeLater(setState)
	print 'Water Updated'
	return

def updateBatch():		
	#------UPDATE BatchSheetGeneral table----------------------------------
	BatchSheetDate=event.source.parent.getComponent('ContainerGeneral').getComponent('Popup Calendar').date
	MoldID=event.source.parent.getComponent('ContainerGeneral').getComponent('MoldType').selectedValue
	ChildFaceMixID=event.source.parent.getComponent('ContainerGeneral').NewFaceMixID
	SampleBoard=event.source.parent.getComponent('ContainerGeneral').getComponent('SampleBoard').intValue
	SampleVolume=round(event.source.parent.getComponent('ContainerGeneral').getComponent('SampleVolume').floatValue,8)
	CreatedBy=event.source.parent.getComponent('ContainerGeneral').getComponent('CreatedBy').text
	ExcecutedBy=event.source.parent.getComponent('ContainerGeneral').getComponent('ExcecutedBy').text
	BatchObjective=event.source.parent.getComponent('ContainerGeneral').getComponent('Objective').text
	BatchSheetSpecialNote=event.source.parent.getComponent('ContainerGeneral').getComponent('BSSpecialNotes').text
	VBUFID=event.source.parent.getComponent('ContainerGeneral').getComponent('VBUF').selectedValue
	ProductTypeID=event.source.parent.getComponent('ContainerGeneral').getComponent('ProductType').selectedValue
	UseTypeID=event.source.parent.getComponent('ContainerGeneral').getComponent('UseType').selectedValue
	ProductColorID=event.source.parent.getComponent('ContainerGeneral').getComponent('Color').selectedValue
	BatchSizeKg=round(event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('BatchSizeKg').floatValue,2)
	BatchSolidPorcent=round(event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerSolids').getComponent('SolidPorcent').floatValue,2)
	BatchSolidMassKg=round(BatchSizeKg * BatchSolidPorcent/100,2)
	BatchLiquidKg=round(BatchSizeKg - BatchSolidMassKg,2)
	BatchLiquidPorcent=round(100 - BatchSolidPorcent,2)
	WaterDensity=round(event.source.parent.getComponent('ContainerGeneral').getComponent('ContainerLiquid').getComponent('WaterDensity').floatValue,2)
	WaterVolume=round(BatchLiquidKg / WaterDensity,4)
	BatchWC=event.source.parent.getComponent('ContainerGeneral').getComponent('wc').floatValue
	BatchSheetID=event.source.parent.getComponent('ContainerGeneral').getComponent('DropdownBatchSheet').selectedValue
	
	if UseTypeID == 2 or UseTypeID != 2 and MoldID > 0: #ensure mold type is selected for throughbody and base mixes
		querylist = [BatchSheetDate,MoldID,ChildFaceMixID,
					SampleBoard,SampleVolume,CreatedBy,
					ExcecutedBy,BatchObjective,BatchSheetSpecialNote,
					VBUFID,ProductTypeID,UseTypeID,ProductColorID,
					BatchSizeKg,BatchSolidPorcent,BatchSolidMassKg,
					BatchLiquidKg,BatchLiquidPorcent,WaterDensity,
					WaterVolume,BatchWC,
					BatchSheetID]
			
		query = """UPDATE BatchSheetGeneral SET BatchSheetDate = ?,MoldID=?,ChildFaceMixID=?,
					SampleBoard=?,SampleVolume=?,CreatedBy=?,
					ExcecutedBy=?,BatchObjective=?,BatchSheetSpecialNote=?,
					VBUFID=?,ProductTypeID=?,UseTypeID=?,ProductColorID=?,
					BatchSizeKg=?,BatchSolidPorcent=?,BatchSolidMassKg=?,
					BatchLiquidKg=?,BatchLiquidPorcent=?,WaterDensity=?,
					WaterVolume=?,BatchWC=?
					WHERE BatchSheetID=?"""
						
		system.db.runPrepUpdate(query, querylist)
		shared.later.invokeLater(refreshComps)
		shared.later.invokeLater(setState)
	else:
		system.gui.messageBox('Mold not selected. Cannot save changes')
	
	print 'Batch Updated'
	return

#Disable Buttons
event.source.parent.cursorCode = 3 #show updating cursor
event.source.parent.getComponent('Button 4').componentEnabled = 0
event.source.componentEnabled = 0

system.util.invokeLater(updateBatch)
system.util.invokeLater(updateWater)
system.util.invokeLater(updateRM)
system.util.invokeLater(updateBinder)
system.util.invokeLater(updateAdmix)

#system.util.invokeLater(setState, 5000) #set state of all components on screen in 5 seconds
#system.util.invokeLater(updateWater, 5000) #update water fields in batchsheetgeneral table in 5 seconds
#system.util.invokeLater(updateRM, 5000) #update raw material table in 5 seconds

[system.db.refresh(event.source.parent, c) for c in comp_list]

I don’t see this working. To use system.db.refresh, you need to do the component path and the property, something like system.db.refresh(event.source.parent.getComponent('ContainerRawMaterial').getComponent('PTRawMaterial'), 'data') like you have in the following line. But if you roll out what your list comprehension, you have

system.db.refresh(event.source.parent, 'BSGeneralState'),
system.db.refresh(event.source.parent, 'CementKg'),
system.db.refresh(event.source.parent, 'LiquidKg'),
...

Which I don’t expect would do anything unless those are properties on the event.source.parent that have bindings. If those are components themselves, though, it should look more like your other statements. Something like

system.db.refresh(event.source.parent.getComponent('BSGeneralState'), 'data'),
system.db.refresh(event.source.parent.getComponent('CementKg'), 'data'),
system.db.refresh(event.source.parent.getComponent('LiquidKg'), 'data'),
...

Each of the components are custom properties on the event.source.parent that are bound

1 Like

Ok just want to make sure all your bases are covered. I assume they’re non-polling sql queries bindings?

Correct all the bounds queries are set to no polling. The custom callLater wrapper doesn’t appear to wait for the future, it seems like it just runs immediately even with the .get() method.