2023-01-25, 15:34
Hi I'm trying to add a background service to my addon. I'm trying to understand how the service in script.embuary.helper works in order to understand.
The thing I am unsure of is... in Embuary helper for example, you can set a service_interval within the script settings between a range of 0.1 and 2.0 - it goes up in 0.1 increments I believe and the default is 0.5.
Is this basically a mulitplier that is applied to some sort of core Kodi interval value used to define how regularly addons monitoring services are run? I assume there must be some sort of bottom floor to assume addons can't abuse system resources. For example, I know skin timers are evaluated every 500ms.
From what I can see in the code, the service_interval is used to control how many times the something will be looped before something happens. But what is the relation between this and real-world time?
E.g. I see this sort of logic in the code.
Apologies if this is very basic or I've misunderstood terminology/code here - I'm still learning the basics of python and coding having previously only learned Kodi skinning.
I understand this to mean that, if service_interval is 0.5, function() will be executed every 600 times the code is run through.
Is there an underlying assumption that the code will be run every 500ms? Or am I supposed to define this somehow in my addon?
PS apologies if this is very basic or I've misunderstood terminology or code here. I'm still learning the basics of coding and python having only previous experience of kodi skinning.
The thing I am unsure of is... in Embuary helper for example, you can set a service_interval within the script settings between a range of 0.1 and 2.0 - it goes up in 0.1 increments I believe and the default is 0.5.
Is this basically a mulitplier that is applied to some sort of core Kodi interval value used to define how regularly addons monitoring services are run? I assume there must be some sort of bottom floor to assume addons can't abuse system resources. For example, I know skin timers are evaluated every 500ms.
From what I can see in the code, the service_interval is used to control how many times the something will be looped before something happens. But what is the relation between this and real-world time?
E.g. I see this sort of logic in the code.
Apologies if this is very basic or I've misunderstood terminology/code here - I'm still learning the basics of python and coding having previously only learned Kodi skinning.
python:
if variable >= 300:
function()
variable = 0
else:
variable += service_interval
I understand this to mean that, if service_interval is 0.5, function() will be executed every 600 times the code is run through.
Is there an underlying assumption that the code will be run every 500ms? Or am I supposed to define this somehow in my addon?
PS apologies if this is very basic or I've misunderstood terminology or code here. I'm still learning the basics of coding and python having only previous experience of kodi skinning.