This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Delaytime not os.sleep()
#5
Hi,

Event based scripts are running in parallel when executed multiple times. To avoid this you need to kill the previous instance of the script. Try using this  and fill it up with your original script and make sure to use a unique storage name for each script you use it in:

Code:
-- check if previous script needs to be killed
storage_name = 'PID_SCRIPT_1'
tpid = storage.get(storage_name)  
if tpid == nil then
   pid = os.getpid()
   storage.set(storage_name, pid)
else
   pid = os.getpid()  
   storage.set(storage_name, pid)  
   os.kill(tpid, signal.SIGKILL)
end

-- put here your script with os.sleep
os.sleep(10)
-- end of your scrript

-- clean up storage
storage.delete(storage_name)

BR,

Erwin
Reply


Messages In This Thread
Delaytime not os.sleep() - by d25m07y1993 - 16.05.2017, 14:14
RE: Delaytime not os.sleep() - by buuuudzik - 16.05.2017, 15:22
RE: Delaytime not os.sleep() - by d25m07y1993 - 16.05.2017, 15:50
RE: Delaytime not os.sleep() - by Erwin van der Zwart - 16.05.2017, 16:58
RE: Delaytime not os.sleep() - by buuuudzik - 16.05.2017, 16:25
RE: Delaytime not os.sleep() - by admin - 16.05.2017, 17:09
RE: Delaytime not os.sleep() - by d25m07y1993 - 17.05.2017, 03:33

Forum Jump: