13.06.2016, 19:59
(This post was last modified: 13.06.2016, 20:42 by Erwin van der Zwart.)
Hi Buuuudzik,
I think the iterate of the result table is taking a lot of resources, especially when having the execution of multiple scripts in parallel from the tag group
You could try to do it with a direct query from DB to avoid the table iterate and speed up things a bit.
You can also add this script in the start of your script to kill previous script when executed multiple times in parallel.
If this doesn't do the trick you can use the semaphore library making it possible to block parallel execution of scripts
See http://openrb.com/docs/semaphore.htm or http://openrb.com/event-script-which-can...rotection/
BR,
Erwin van der Zwart
I think the iterate of the result table is taking a lot of resources, especially when having the execution of multiple scripts in parallel from the tag group
You could try to do it with a direct query from DB to avoid the table iterate and speed up things a bit.
Code:
function tag_or(tag)
local result = db:getall('SELECT id FROM objects WHERE datahex = "01" AND tagcache LIKE "%' .. tag .. '%"')
if #result == 0 then
return false
else
return true
end
end
You can also add this script in the start of your script to kill previous script when executed multiple times in parallel.
Code:
--check for earlier started scrips
storagename = 'TAG_OR' -- Must be unique for every script
--check storage for tpid value
tpid = storage.get(storagename)
--check if tpid has a value
if tpid == nil then
pid = os.getpid()
storage.set(storagename, pid)
else
pid = os.getpid()
-- create new pid for next time to kill
storage.set(storagename, pid)
-- kill earlier running script
os.kill(tpid, signal.SIGKILL)
end
If this doesn't do the trick you can use the semaphore library making it possible to block parallel execution of scripts
See http://openrb.com/docs/semaphore.htm or http://openrb.com/event-script-which-can...rotection/
BR,
Erwin van der Zwart