Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script files are loaded before scripting engine is available #1983

Closed
cweitkamp opened this issue Dec 22, 2020 · 4 comments · Fixed by #2222
Closed

Script files are loaded before scripting engine is available #1983

cweitkamp opened this issue Dec 22, 2020 · 4 comments · Fixed by #2222

Comments

@cweitkamp
Copy link
Contributor

I am using Jython Scripting and installed the bundle for it. During OH3 restarts I am seeing the following info in my logs. One message for each physical file. Approximately 5 min later all the files are reloaded and the rules can be used without an issue. This looks like we can implement a small improvement here.

2020-12-22 10:29:21.331 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.338 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.352 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.358 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.363 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.369 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.373 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.380 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.385 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.391 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.398 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.401 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.405 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.409 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.413 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.417 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.421 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.424 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.428 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.432 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.435 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.439 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
2020-12-22 10:29:21.443 [INFO ] [ab.core.service.AbstractWatchService] - ScriptEngine for py not available
...
2020-12-22 10:36:03.284 [INFO ] [ab.core.service.AbstractWatchService] - Loading script '/etc/openhab/automation/jsr223/python/personal/astro.py'
...
@kaikreuzer
Copy link
Member

Could you analyse what causes these scripts to be reloaded? Although this seems to be a good feature here, I am not really clear on what causes it.

@jpg0
Copy link
Contributor

jpg0 commented Dec 28, 2020

I believe that scripts which are of a type not (yet) registered are stored and then executed when a script engine becomes available. In this case, the ScriptFileWatcher is processing the scripts before the python script engine is available. Once it's available, they are all processed. TBH I'm surprised that there are no issues with scripts referencing things that come up after the engine itself (like #1991).

@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/jython-helper-libraries-for-oh3/110734/35

@cweitkamp
Copy link
Contributor Author

I can confirm that this issue is solved by #2222. I no longer see the mentioned info in my logs during startup. Thanks @jpg0 for fixing it.

I am wondering if #1991 has been solved too because I randomly saw similar error messages (like the following one) in my logs which seem to be gone too:

2021-03-13 11:32:11.458 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab/automation/jsr223/python/personal/household.py': ImportError: cannot import name NotificationAction in /etc/openhab/automation/jsr223/python/personal/household.py at line number 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants