Jump to content




Is there any way to get rid of the "too long without yielding" error?


  • You cannot reply to this topic
9 replies to this topic

#1 BrolofTheViking

  • Members
  • 55 posts

Posted 14 October 2012 - 11:40 PM

I'm running a program that needs to call a loop numerous thousand times, but can't do so because computercraft is stopping it from running the loop for too long.
Is there anyway to circumvent this?

#2 Shazz

  • Members
  • 175 posts

Posted 14 October 2012 - 11:56 PM

Show us your code or else we can't help you.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 15 October 2012 - 12:11 AM

Try yielding. A sleep(0) in the loop should do.

#4 BrolofTheViking

  • Members
  • 55 posts

Posted 15 October 2012 - 12:28 AM

Sorry, wasn't exactly clear I guess
I'm not having a syntax error or anything like that, so I figured that, since this is a generic problem and not specifically related to my program, I wouldn't provide a code that would distract you, looking for syntax errors
Computercraft (or more likely, lua) has a built in thing where it stops infinite loops, by giving an error when a loop iterates too many times.
However, for what I'm doing, I need it to run an amount of times greater than the built in limit.

my code is this http://pastebin.com/FizscyHm
which then creates an 814 kilobyte long file (17,576 blocks). I can't make it record an area any larger than that one.
I believe that I may have misinterpreted the error. Rather than the problem being that the loop runs too far, I probably just gave the write() function too much.

However, the question still stands: Is it possible to get past the recursion limit built into Lua?

#5 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 15 October 2012 - 12:33 AM

View PostBrolofTheViking, on 15 October 2012 - 12:28 AM, said:

Sorry, wasn't exactly clear I guess
I'm not having a syntax error or anything like that, so I figured that, since this is a generic problem and not specifically related to my program, I wouldn't provide a code that would distract you, looking for syntax errors
Computercraft (or more likely, lua) has a built in thing where it stops infinite loops, by giving an error when a loop iterates too many times.
However, for what I'm doing, I need it to run an amount of times greater than the built in limit.

my code is this http://pastebin.com/FizscyHm
which then creates an 814 kilobyte long file (17,576 blocks). I can't make it record an area any larger than that one.
I believe that I may have misinterpreted the error. Rather than the problem being that the loop runs too far, I probably just gave the write() function too much.

However, the question still stands: Is it possible to get past the recursion limit built into Lua?
removing the yielding error has been asked before, and it will not happen

and wait, recursion limit? that has nothing to do with yielding errors xD

#6 Fatal_Exception

  • New Members
  • 105 posts

Posted 15 October 2012 - 12:58 AM

It's a timeout error, not a recursion limit. Literally, it's been too long since you've given another process the chance to run. Your program is not playing nice in a co-operative multitasking environment, so it's been sent to sit in the corner.

The solution is as Lyqyd said. Throw in some sleep(0) to let it yield.

#7 BrolofTheViking

  • Members
  • 55 posts

Posted 15 October 2012 - 01:04 AM

Ah, I see. Well, I misinterpreted that then, I assumed that it was something similar to what I had seen in other languages. Another stupid point for me today, damnit.

#8 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 15 October 2012 - 12:44 PM

If i may ask, how does sleep(0) help? Doesn't it make it sleep for 0 seconds which is nothing? Just curious

#9 GopherAtl

  • Members
  • 888 posts

Posted 15 October 2012 - 12:53 PM

You have to understand how cooperative multitasking works. Most things these days use preemptive multitasking, meaning some control process forcibly ends one thread to let others run. Cooperative multitasking doesn't do this; each process has to yield before the next one can run. Any functions that wait for something - pullEvent, sleep, rednet.receive, many of the turtle functions - wait by yielding until some event happens. This is what sleep(0) does - it yields, so any other tasks can run. Sleeping for 0 just means it will resume as soon as its turn comes up again, where sleep(5) would not resume until at least 5seconds have passed.

#10 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 15 October 2012 - 12:56 PM

That's pretty awesome.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users