Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

limitations to WHILE loop?


Guest reiniertc

Question

Guest reiniertc
Posted

I've made a scene with a WHILE loop, but somehow it stops after aprox 6 hours.

 

 

the basic setup of the scene is:

Please login or register to see this code.

 

while true do [some code that runs function 1 and function 2
wait for 55 seconds by using function 3 end

 

 

Are there any know generic limitations to a WHILE loop that would cause it to stop after 6 hours? 

 

 

 

7 answers to this question

Recommended Posts

  • 0
Posted

not that i know of. 

  • 0
Posted

"While" doesn't crash by itself. But some lua code can crash. It can happen to http calls. You can catch these errors with "pcall" (please search this forum or check the lua manual).

  • 0
Guest reiniertc
  • Inquirer
  • Posted

    thanks petergebruers, maybe some http calls might cause the scene to stop.

    I will search the forum on "pcall"

    • 0
    Guest reiniertc
  • Inquirer
  • Posted

    mmm... the scene quits again after 6 hours when I use pcall, but no errors show up

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    • 0
    Posted

    mmm... the scene quits again after 6 hours when I use pcall, but no errors show up

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    I hate to say it, I'm quite certain that it's your script. I mean, it's not the "while" loop. It was never mentioned before on the forum and I have several scripts with an infinite loop. But none of them use http, that's why I thought about the pcall. What has been mentioned before is that the main loop of a virtual device stops working, and that's essentially a (non-visible) infinite loop. So maybe you've discovered a related problem.

    Would it be possible to reduce your script to the absolute minimum, with a maximum of 10 lines of code, so someone can try to reproduce your problem?

    • 0
    Guest reiniertc
  • Inquirer
  • Posted

    I've made some infinite while loops with almost no code: no problems there.

    So indeed Peter: It must be the script.

     

    so now I've reduced the code in my problamatic while loop.

    At first, I've greyed out the content of the two  functions that are called every minute.

    If the result is that the while loop works fine, the problem must be in one of the two functions.

     

    If the problem is still there, I'm gonna undo the greying out of the functions and reduce the amount of function calls every minute.

     

     

    ps: the script itself doesnt contain http-calls, it calls some virtual device buttons that performs the actual http call

    • 0
    Posted

    Sounds like a plan!

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" /> Thanks for the feedback!

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...