When I call luup.call_timer from a block, the named function is called. And called again a few moments later. And again later. And again and again.
But when all I do is change the block to a block, the named function is called just the once, as it should be. Also, when called from a block, local data that is intended to damper over-polling is not initialized, as if running in a context is materially different from running in a block.
This is on 1.5.408.
Can anyone explain this very irritating behavior? For now, I have to revert my blocks to blocks in order to avoid this insane enthusiasm for calling my function on a timer.
Would love to have any insight other plugin developers may have on this!
Not seen it before, but a few things I’d try/check:
if I need a one shot, I might switch to luu.call_delay instead of call_timer.
check to see if I have the explicit RETURN codes set at the end of the Job code.
In the past there were odd behaviors, in some functions, when an explicit return (with the right codes) wasn’t done… In these cases, the behavior would depend upon how internal memory had/hadn’t been initialized by MCV prior to the call.
a JOB block is already running async, can I take advantage of that instead of launching another task.
Another thing to be aware of is that // is only useful if your plugin has a serial stream to read from (i.e., you have done a luup.io.open() and you communicate with the real-world device using luup.io.write()) and that stream receives bytes asynchronously.
If you communicate with your real-world device using Luasocket instead (say, because it has a RESTful interface) then using / to retry the request will ALWAYS lead to the job failing, no matter what you put in the block.
This reliance on a serial stream appears to be an undocumented assumption about built into the LuaUPnP design.
I did some extensive testing of this with the WeMo plugin, and concluded that using could never succeed. I fell back to using .
I am in the process of moving to JOB for the PL plugins …
According to McvFlorin, if you get more RUN requests faster than they process … they can trigger some deadlock logic and will cause LuaPnP to restart.
My activities might have been at most a second or two, depending how many and how long my actions (equivalent of a scene) were taking to run.
And yes I have some problems already.
You are supposed to be able to queue up JOB requests … That’s why I am refactoring.
I changed VeraAlert since it does http request to a Google server. It seems to be working OK.
Doing Network activities in a RUN block could lead to a LuaPnP restart … if you received a burst of requests.
This is all incredibly helpful information. Thank you guessed, futzle, and Richard very much!
I have not heard reports of leading to problems with the Nest plugin (or rather, unexpected restarts due to deadlock problems related to the plugin), so I’m going to leave it, and the ecobee plugin, using . Both plugins using https.request exclusively for I/O. Watching luup.call_timer() behave so unexpectedly in a block but not a block is enough for me to leave it as is, until I see problems.
Thanks again!
watou
Best Home Automation shopping experience. Shop at Ezlo!