Jump to content

[TUT] Disable the infinite loop protection


guix

Recommended Posts

There is a protection in Lua that prevent infinite loops from blocking the server forever.

Sometimes (when testing things) you may need a huge loop that you know will not be infinite, but unfortunately it could still trigger that protection, so here is how to disable it temporarily:

  
local h1, h2, h3 = debug.gethook() 
debug.sethook() 
  
-- Your loop here 
  
debug.sethook( _, h1, h2, h3 ) 
  

I hope it will be useful for someone else :)

Link to comment
  • 1 year later...
A more sensible approach would be to make use of timers. Set a very frequent timer and execute the loop in portions. Your method will simply stall the server and all players will eventually time out.

It depends on the use, I just used it to import +2000000 mysql rows to a sqlite database.

Thanks to OP :D

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...