21.12.2023, 13:43
Description:
I am encountering an issue with my Lua script. The problem is illustrated here with a simplified version to expose the general architecture, but it's in my more complex and extensive code that the bug manifests. During increased CPU load, the complete script seems to enter an infinite loop with CPU usage exceeding 100%, specifically stalling on the 'copas.step()' instruction.
Context:
This ticket presents a simplified version of the code to illustrate the architecture and facilitate discussion. However, the problem occurs in the larger and complete version of the script.
Code snippet (simplified for illustration):
Problem Encountered:
High CPU usage and entering an infinite loop in the complete version of the script during periods of load.
Specific stalling on the 'copas.step()' instruction.
Impact:
This situation completely blocks the operation of the script.
Request:
I am seeking assistance to diagnose and resolve this issue in the context of the complete version of my script. Advice on the general architecture as well as specific suggestions to avoid this kind of stalling would be extremely useful.
I am encountering an issue with my Lua script. The problem is illustrated here with a simplified version to expose the general architecture, but it's in my more complex and extensive code that the bug manifests. During increased CPU load, the complete script seems to enter an infinite loop with CPU usage exceeding 100%, specifically stalling on the 'copas.step()' instruction.
Context:
This ticket presents a simplified version of the code to illustrate the architecture and facilitate discussion. However, the problem occurs in the larger and complete version of the script.
Code snippet (simplified for illustration):
Code:
if not client then
client = require('localbus').new(0.1)
function eventhandler(event)
local eventObject = grp.find(event.dst)
eventObject.data = knxdatatype.decode(event.datahex, eventObject.datatype)
copas.addthread(function()
log("first thread launching other threads")
-- do some stuff
copas.addthread(function()
log("second level thread 1")
-- do some stuff
end)
copas.addthread(function()
log("second level thread 2")
-- do some stuff
end)
end)
end
client:sethandler('groupwrite', eventhandler)
end
log("bug lb")
client:loop(1)
log("bug copas")
copas.step()
Problem Encountered:
High CPU usage and entering an infinite loop in the complete version of the script during periods of load.
Specific stalling on the 'copas.step()' instruction.
Impact:
This situation completely blocks the operation of the script.
Request:
I am seeking assistance to diagnose and resolve this issue in the context of the complete version of my script. Advice on the general architecture as well as specific suggestions to avoid this kind of stalling would be extremely useful.