Python Plugin: best way to do asynchronous work?

Python and python framework

Moderator: leecollings

Post Reply
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Python Plugin: best way to do asynchronous work?

Post by blauwebuis »

What is the 'official' way to do asynchronous calls in the python plugin framework?

For example, I'm getting data form bluetooth low energy devices. That takes a while, and there could be a communication time-out. In order to not hang the entire system, I created a second python script that does the unpredictable work. That worked for the 433 RF Switches plugin (which resords and breadcasts RF signals). I also tried doing this for a new plugin for Mi Flower Mate sensors which work over Bluetooth LE. But there I ran into an error.

Ideally each python plugin would run as its own asynchronous proces. I'm curious: why doesn't it work like that?

And more practical: are there other ways to do this that are recommended? Spawn a new python thread perhaps?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest