This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheModerGuy's profile picture

Too Long Without Yielding On Previously Working Code

Started by TheModerGuy, 30 August 2013 - 09:41 PM
TheModerGuy #1
Posted 30 August 2013 - 11:41 PM
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
bigbaddevil6 #2
Posted 31 August 2013 - 12:30 AM
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.
KaoS #3
Posted 31 August 2013 - 12:52 AM
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
BigTwisty #4
Posted 31 August 2013 - 03:04 AM
I've always found that if you increase the os.sleep time this particular problem tends to go away.
CCJJSax #5
Posted 31 August 2013 - 03:40 AM
I find that sleep(0) is pretty pointless ;)/> I would up that time and things should work fine
floppyjack #6
Posted 31 August 2013 - 08:12 AM
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.
CCJJSax #7
Posted 31 August 2013 - 03:36 PM
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.
KaoS #8
Posted 01 September 2013 - 01:16 PM
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