[SailfishDevel] Using Python's "sched" module

Camil Bancioiu ioan.camil.bancioiu at gmail.com
Fri Nov 28 20:02:59 UTC 2014


Hello,

What's the best way to set up a timer for a longer period in SailfishOS, without worrying about a live thread that's draining the battery?

My app needs to schedule some events repeatedly as a day passes (for example, do something once every hour, and sleep between the events). Python has the "sched" module, which seems to be appropriate for this task. But is it appropriate for using on a mobile phone? I'm mostly concerned that the "scheduler" object from this module will drain the battery while waiting for the next event, and that wouldn't be ok. According to the documentation, one can configure the "scheduler" to use "time.sleep()" for waiting, which should suspend the thread completely (absolutely no activity) until the operating system wakes it up, right? I might be paranoid here: this looks like a good solution, but I would like someone more knowledgeable to confirm that it's safe to use Python's "sched" module without worrying.

Many thanks!


More information about the Devel mailing list