←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

Too Long Without Yielding On Previously Wo...

TheModerGuy's Photo TheModerGuy 30 Aug 2013

I'm not sure if its a bug with computer craft or my code but all of the computers on my servers using while true loops keep getting "too long without yielding"

my situation:
version : 1.5.2
Computercraft version : 1.53
what i think the error: probably something to do with the tps
other mods : FTB Unleashed 1.5.2

OK so i had code on my pastebin from 1.4.7 here is the code:

term.clear()
term.setCursorPos(1,1)
os.setComputerLabel("TMG"..os.getComputerID())
print("Killing Mobs...")

while true do
	  for i=1,3 do
		   turtle.select(i)
		   turtle.drop()
	  end
	  turtle.attack()
	  sleep(0)
end

after a few hours it stops and spits out too long without yielding, I've done everything i can think of to fix it but no go.
i get the same error on another computer too and its not even a turtle:

too big to paste here so: http://pastebin.com/QRDqnUJM

Attached Thumbnails

  • Attached Image
Quote

bigbaddevil6's Photo bigbaddevil6 30 Aug 2013

i had that problem in 1.4.7 with the DW20 pack it had to do with miscperipherals had a problem i haven't played on the unleashed pack so im not sure if there any conflicts or not. in current releases of the mods it seems to be working fine. If it is the code im sure a smarter mind than mine will figure it out.
Quote

KaoS's Photo KaoS 30 Aug 2013

If your computer is too slow or you have too many CC computers running or some bastard is using exploits to screw you then this will happen. Unfortunately there is nothing you can do about the latter
Quote

BigTwisty's Photo BigTwisty 31 Aug 2013

I've always found that if you increase the os.sleep time this particular problem tends to go away.
Quote

CCJJSax's Photo CCJJSax 31 Aug 2013

I find that sleep(0) is pretty pointless ;) I would up that time and things should work fine
Quote

floppyjack's Photo floppyjack 31 Aug 2013

 CCJJSax, on 31 August 2013 - 02:40 AM, said:

I find that sleep(0) is pretty pointless ;) I would up that time and things should work fine

I just did some research & testing and it turns out that the sleep function calls coroutine.yield, so increasing the time should not make any difference.
Quote

CCJJSax's Photo CCJJSax 31 Aug 2013

Perhaps you could have some reboot thing. After so many times of it going through, maybe it should get a good reboot. I know this is a little out there, but I think it's worth a shot.
Quote

KaoS's Photo KaoS 01 Sep 2013

rebooting doesn't really solve the issue hey. In reality all of the turtle actions yield too so that sleep is entirely unnecessary. If you are the server owner run a search through the CC files for "coroutine" and "parallel". If someone has something that created a new thread every time it is used or has a coroutine that pretty much just yields then toss him out/delete that prog and it just might sort out your issue. It will improve the speed of your computers for sure
Quote