Posted 20 February 2015 - 02:13 PM
CC 1.7 (through to at least 1.74), MC 1.7.10, Forge 10.13.1.1219.
If more than ~256 commands have been requested at a time via commands.execAsync(), their respective "task_complete" events will stop firing. For one thing, this makes it difficult to measure the amount of commands that're still pending execution (… a figure which may lead to a "task limit exceeded" error if it's allowed to grow unchecked, or to my other script outright "stalling" for reasons I haven't nailed down yet but I certainly hope don't involve commands.execAsync() yielding!).
Use the following to verify (this code fails due to the event queue being flooded, see two posts down for an example that fails without doing so):
Tweaking maxCommands down to around 256 (or less), on the other hand, works, and you shouldn't have to go much higher in order to trigger the stall. These symptoms also exist under 1.66pr3 (I've not had access to a 1.66 build older than that).
TLDR version:
Too many commands being executed at once result in the event queue being flooded, no matter how fast you try to pull them.
But even if you don't go anywhere near flooding the queue, while commands are running events have a random chance of not making it in there (affecting timer events, command events, and presumably others too).
If more than ~256 commands have been requested at a time via commands.execAsync(), their respective "task_complete" events will stop firing. For one thing, this makes it difficult to measure the amount of commands that're still pending execution (… a figure which may lead to a "task limit exceeded" error if it's allowed to grow unchecked, or to my other script outright "stalling" for reasons I haven't nailed down yet but I certainly hope don't involve commands.execAsync() yielding!).
Use the following to verify (this code fails due to the event queue being flooded, see two posts down for an example that fails without doing so):
Spoiler
local firedCommands, pendingCommands, completeCommands, maxCommands = 0, 0, 0, 10000
local curX, curY = term.getCursorPos()
local x, y, z = commands.getBlockPosition()
parallel.waitForAll(
function()
for i = 1, maxCommands do
commands.execAsync("setblock "..tostring(x).." "..tostring(y+1).." "..tostring(z).." minecraft:stone 0")
firedCommands = firedCommands + 1
pendingCommands = pendingCommands + 1
end
end,
function()
while true do
os.pullEvent("task_complete")
pendingCommands = pendingCommands - 1
completeCommands = completeCommands + 1
if completeCommands == maxCommands then break end
end
end,
function()
while true do
term.setCursorPos(1, curY)
term.clearLine()
term.write("Fired: "..tostring(firedCommands).." Pending: "..tostring(pendingCommands).." Complete: "..tostring(completeCommands))
if completeCommands == maxCommands then break end
sleep(1)
end
end)
print("\nDone.")
Tweaking maxCommands down to around 256 (or less), on the other hand, works, and you shouldn't have to go much higher in order to trigger the stall. These symptoms also exist under 1.66pr3 (I've not had access to a 1.66 build older than that).
TLDR version:
Too many commands being executed at once result in the event queue being flooded, no matter how fast you try to pull them.
But even if you don't go anywhere near flooding the queue, while commands are running events have a random chance of not making it in there (affecting timer events, command events, and presumably others too).
Edited on 06 November 2015 - 09:58 PM