Page 1 of 1

Python Plugin: best way to do asynchronous work?

Posted: Tuesday 20 February 2018 13:57
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?