Jan-20-2017, 05:51 PM
I have been using a Tingbot which runs on a modified version of Jessie. There is an interesting feature (called a decorator) in the Tingbot Python that would be nice to have in Python in general, so I am wondering if there is anything similar to this feature? (From the Tingbot Python documentation):
@every(hours=0, minutes=0, seconds=0)
This decorator will call the function marked periodically, according to the time specified.
Example: Refreshing data every 10 minutes
@every(minutes=10)
def refresh_data():
r = requests.get('ht**://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f')
state['data'] = r.json()
@every(hours=0, minutes=0, seconds=0)
This decorator will call the function marked periodically, according to the time specified.
Example: Refreshing data every 10 minutes
@every(minutes=10)
def refresh_data():
r = requests.get('ht**://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f')
state['data'] = r.json()