I want to execute two Stored Procedures asynchronously i.e., one after the another.
SP_COATING_DASH_2 executes in 4.6 secs and
SP_SET_LOCK_DASH executes in less than 1 sec.
In my script, I have:
## Code for running SP's to DAILY_DASH
## At 11:59 AM on every Thursday Night
## The gateway script should check every one min OR @60,000 ms
import system
import time
from datetime import datetime
dateFormat ="%Y-%m-%d %H:%M:%S"
currentDate = system.db.dateFormat(system.tag.read("CurrentDateTime").value,"yyyy-MM-dd HH:mm:ss") ## Get date from the Tag
## pythonDate = datetime.now();
currentDatePython = datetime.strptime(currentDate,dateFormat) ## Convert the date to datetime format
currentDayOfWeek = currentDatePython.weekday() ##{Mon = 0, Tue=1, Wed = 2, *Thu = 3*, Fri = 4, Sat = 5, Sun = 6}
currentHour = currentDatePython.hour ## Range(0,24)
currentMin = currentDatePython.minute ## Range (0,60)
currentSec = currentDatePython.second ## Range (0,60) ## We may not need seconds in this code
if currentDayOfWeek == 3: ##Thursday
if currentHour == 23: ## 11 AM
if currentMin == 59: ## 11:59 AM
##Create SP Calls here
coater = system.db.createSProcCall("SP_COATING_DASH_2","OPFIS")
setLockToOne = system.db.createSProcCall("SP_SET_LOCK_DASH","OPFIS")
## Add SP Calls for other Stored Procedures as well here
system.db.execSProcCall(coater)
## The lock should be set to 1 after all these stored procedures are called!
time.sleep(1) # sleep for 1s
system.db.execSProcCall(setLockToOne) ## Set Lock = 1 to all the rows
Should I use the time.sleep function (or) execute it using the invokeLater? This is a gateway timer script that runs @ every 60,000 ms and checks whether it is Thursday, 11:59 AM and updates the tables!