Page 1 of 1

threading in Python plugin

Posted: Monday 24 June 2019 12:50
by nhale25
Hi, I see on the wiki [1] it says that a future version will support threading in a Python plugin.I'm wondering if that information is up to date. I'm running version 4.10717, and looking in git, it looks like at least the threading example plugin script is in that version, so can I expect threading to work? Or am I misinterpreting?

I'm currently working on a plugin for TP-Link plugs and bulbs. Due to limitations in the Connection API, and to avoid blocking, I'm having to do certain things in a different thread and everything does seem to be working as expected.

My other question is (assuming threading is supported in this version): Is there any information on using the plugin API safely from other threads? For example, can I make a device and call Device.Create() from another thread? Do I need to manually synchronise access to the the Devices dictionary?

Thanks

[1] https://www.domoticz.com/wiki/Developin ... rk_details:

Re: threading in Python plugin

Posted: Monday 24 June 2019 13:14
by pipiche
Yes it is available and as an example you have one here: https://github.com/domoticz/domoticz/bl ... hreaded.py