Just thought I’d post this here in case someone else runs into this …
I was seeing a strange run-time error in my logs for my jsr223 jython code:
2022-09-23 20:54:49.083 [WARN ] [ore.internal.scheduler.SchedulerImpl] - Scheduled job '<unknown>' failed and stopped
org.python.core.PyException: TypeError: 'bool' object is not callable
at org.python.core.Py.TypeError(Py.java:236) ~[?:?]
at org.python.core.PyObject.__call__(PyObject.java:396) ~[?:?]
at org.python.core.PyObject.__call__(PyObject.java:477) ~[?:?]
at org.python.core.PyObject.__call__(PyObject.java:481) ~[?:?]
at org.python.pycode._pyx2333.f$4(/etc/openhab/automation/jsr223/python/personal/DoorWarnings.py:99) ~[?:?]
at org.python.pycode._pyx2333.call_function(/etc/openhab/automation/jsr223/python/personal/DoorWarnings.py) ~[?:?]
at org.python.core.PyTableCode.call(PyTableCode.java:173) ~[?:?]
at org.python.core.PyBaseCode.call(PyBaseCode.java:119) ~[?:?]
at org.python.core.PyFunction.__call__(PyFunction.java:406) ~[?:?]
at org.python.core.PyFunction.__call__(PyFunction.java:401) ~[?:?]
at org.python.core.PyFunction.invoke(PyFunction.java:547) ~[?:?]
at com.sun.proxy.$Proxy616.apply(Unknown Source) ~[?:?]
at org.openhab.core.model.script.actions.ScriptExecution.lambda$0(ScriptExecution.java:97) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:191) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:88) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
It was being generated by a ScriptExecution timer expiring … there wasn’t much info in the log to help, except that it seemed to be trying to execute a boolean when it should have been a function.
After scratching my head for a while in trying to reproduce it, I started to compare the code with an older version I had. I found that I had recently added some new code to test for some event and used a global boolean variable that had the same name as the lambda timer function … I was surprised that the compiler doesn’t catch this, or at least generate a warning… anyway, my mistake.
So lesson learned, always make sure your variables (especially global ones) don’t accidentally have the same name as one of your functions!