Plugin do not start !!! Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Plugin do not start !!!

Post 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
SweetPants

Re: Plugin do not start !!!

Post by SweetPants »

Which plugin are you talking about?
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Plugin do not start !!!

Post 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
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin do not start !!!

Post 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
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Plugin do not start !!!

Post 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
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin do not start !!!

Post 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?
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Plugin do not start !!!

Post 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
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Plugin do not start !!!

Post by pipiche »

Or is the issue is related to libraries used at compile/link time ?



Envoyé de mon iPhone en utilisant Tapatalk
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin do not start !!!

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Plugin do not start !!!

Post by pipiche »

Sound good.
Btw, does that mean the plugin can start thread on its own ?


Envoyé de mon iPhone en utilisant Tapatalk
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin do not start !!!

Post by Dnpwwo »

Yes.

Have a look at https://github.com/dnpwwo/Domoticz-Google-Plugin for an example, particularly onStop for the thread shutdown.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Plugin do not start !!!

Post by pipiche »

What that is the direction I wanted the plugin framework to go. Great enhancement
Post Reply