Page 1 of 1

Plugin do not start !!!

Posted: Friday 22 February 2019 15:42
by pipiche
When starting the plugin, it stuks at the beginning/initialisation. Even not a single line of the plugin executed !

the log file show:

PluginSystem: Entering work loop
(Hardware Name) Initialized version <version from plugin.py>, author '<author from plugin'>

Try to put the plugin in Debug, but as we even do not execute even the 1st line of the plugin onStart !

Domoticz V 4.9700
dpkg --get-selections| grep libpython
libpython-stdlib:armhf install
libpython2.7-minimal:armhf install
libpython2.7-stdlib:armhf install
libpython3-dev:armhf install
libpython3-stdlib:armhf install
libpython3.5:armhf install
libpython3.5-dev:armhf install
libpython3.5-minimal:armhf install
libpython3.5-stdlib:armhf install

Re: Plugin do not start !!!

Posted: Friday 22 February 2019 22:47
by SweetPants
Which plugin are you talking about?

Re: Plugin do not start !!!

Posted: Friday 22 February 2019 22:49
by pipiche
Basically it seems that if you take the Base Template plugin in examples and you add

Import sqlite3

The plugin will not start.

At least it happens with V4.9700 of Domoticz


Envoyé de mon iPhone en utilisant Tapatalk

Re: Plugin do not start !!!

Posted: Friday 22 February 2019 23:23
by Dnpwwo
@pipiche,

Only 2 things I can think of:
  • Recent changes to plugin startup around adding sitepackages (although that was made a few weeks ago with no one reporting issues on this forum)
  • One of your plugins is executing code prior to onStartup being called that is getting stuck which seems more likely. Python implements this weird version of 'Import' because it actually does an 'Import and Execute' of the module. I would recommend moving all 'import' statements (apart from Domoticz) into onStart and calling the Domoticz.Trace as the first line in onStart function to show where the issue is

Re: Plugin do not start !!!

Posted: Saturday 23 February 2019 9:15
by pipiche
In fact I’m able to duplicate the issue with the simple Base Template from plugins/examples by adding import sqlite3

This is with Domoticz v4.9700 (stable).




Envoyé de mon iPhone en utilisant Tapatalk

Re: Plugin do not start !!!

Posted: Saturday 23 February 2019 10:02
by Dnpwwo
@pipiche,

Pretty sure that the Plugin Framework in the Domoticz stable build does not support threads in plugins and that sqlite3 uses them which would most likely be the cause of this.

I tried sqlite3 the other day in the Beta version and it worked. Have you tried that?

Re: Plugin do not start !!!

Posted: Saturday 23 February 2019 10:09
by pipiche
Yes agree on beta no issue at all.
Did you change so much on the framework that now it support thread on beta and when it will move to stable it will work ?


Envoyé de mon iPhone en utilisant Tapatalk

Re: Plugin do not start !!!

Posted: Saturday 23 February 2019 10:09
by pipiche
Or is the issue is related to libraries used at compile/link time ?



Envoyé de mon iPhone en utilisant Tapatalk

Re: Plugin do not start !!!

Posted: Saturday 23 February 2019 11:08
by Dnpwwo
@pipiche,

Not related to compile or link at all because Python is late linked at runtime to ensure Domoticz will still run if Pyhton is not on the server at all. Also allows Domoticz to run with any version after 3.4.

The change will make it into the next Stable because it was required for Python 3.7+ support but I implemented for, and tested against, 3.6, 3.5 and 3.4 and it seemed to work pretty well so far.

One caveat though: any additional threads are started by any libraries must be shut down in onStop explicitly by the plugin otherwise Domoticz will abort during a restart of the hardware. This is a Python 'feature' not a Plugin Framework issue.

Re: Plugin do not start !!!

Posted: Saturday 23 February 2019 11:54
by pipiche
Sound good.
Btw, does that mean the plugin can start thread on its own ?


Envoyé de mon iPhone en utilisant Tapatalk

Re: Plugin do not start !!!

Posted: Sunday 24 February 2019 2:00
by Dnpwwo
Yes.

Have a look at https://github.com/dnpwwo/Domoticz-Google-Plugin for an example, particularly onStop for the thread shutdown.

Re: Plugin do not start !!!

Posted: Sunday 24 February 2019 9:25
by pipiche
What that is the direction I wanted the plugin framework to go. Great enhancement