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

Serialize Errors With "too Long Without Yielding"

Started by campicus, 25 August 2013 - 04:35 AM
campicus #1
Posted 25 August 2013 - 06:35 AM
As the title says, when I serialize my table (line 77) it can error with "too long without yielding". This doesn't happen often at all, however as it is my mining program it basically runs 24/7. Any ideas why this happens?

For those too lazy to go to pastebin, this is the relevant code:

Spoiler

function trackPos()
  position = {xPos, yPos, zPos, facing, long, wide, deep}
  h = fs.open("GPS", "w")
  h.write(textutils.serialize(position))
  h.close()
end

Pastebin:
http://pastebin.com/CfDr1uNr
campicus #2
Posted 25 August 2013 - 08:10 PM
Nobody has any ideas? :s
Imred Gemu #3
Posted 25 August 2013 - 11:24 PM
Could you please post the exact error message, I can't tell if it's a bug in your code on in texutils.
jay5476 #4
Posted 26 August 2013 - 01:24 AM
well first off…

function trackPos()
  position = {xPos, yPos, zPos, facing, long, wide, deep}
  h = fs.open("GPS", "w")
  h.write(textutils.serialize(position))
  h.close()
end
xPos etc. are declared outside of the function i dont know if that will cause it to error but it would be safer to do
function trackPos(xPos, yPos, zPos, facing, long, wide, deep)
  position = {xPos, yPos, zPos, facing, long, wide, deep}
  h = fs.open("GPS", "w")
  h.write(textutils.serialize(position))
  h.close()
end
trackPos() -- with relitive terms eg. trackPos(1,2,3,"north",5,8,10)
see if that makes a difference
Bubba #5
Posted 27 August 2013 - 10:35 AM
This is a too long without yielding error. You would not experience that error because of missing variables, jay.

@OP Try addding in something like this before and/or after a call to trackPos:

os.queueEvent("trash_event")
coroutine.yield()
McLeopold #6
Posted 27 August 2013 - 11:23 AM
Can you pastebin the contents of you GPS file when it times out again?
campicus #7
Posted 27 August 2013 - 09:46 PM
Can you pastebin the contents of you GPS file when it times out again?

The GPS file was empty, nothing in it at all but it did exist.

Could you please post the exact error message, I can't tell if it's a bug in your code on in texutils.

The funny thing is I got an error msg relating to my code on one turtle, and an error message relating to textutils on another turtle. Both were "too long without yielding".

My turtles haven't done this again since I changed my code to this:


function trackPos()
  position = {xPos, yPos, zPos, facing, long, wide, deep}
  h = fs.open("GPS", "w")
  h.write(textutils.serialize(position))
  sleep(0.1)
  h.close()
end

If it happens again I will record the exact error before breaking the turtle (duh) and report back. Will also try everyone's suggestions. Thanks to everyone that responded :)/>
immibis #8
Posted 28 August 2013 - 04:40 AM
It's almost certainly a bug in your code. It just happened to be inside serialize when the timer ran out. Post your full code.
Bubba #9
Posted 28 August 2013 - 07:42 AM
It's almost certainly a bug in your code. It just happened to be inside serialize when the timer ran out. Post your full code.

The OP did post his full code. See his first post again.