NameError: name 'cron' is not defined

350 Views Asked by At

I am trying to create a VOLTTRON actuator agent that has a linux CRON like feature to schedule tasks. My experiment is to fire off some generic HTTP requests grequests on a CRON like schedule.

I can create a function in Python like the example states from the link:

@Core.schedule(cron('0 1 * * *'))
def cron_function(self):
   print("this is a cron-scheduled function")

But I get a NameError: name 'cron' is not define Maybe I am missing something where the example from the documentation is missing an import module for using a cron feature. Any tips help this is my script in a Git Gist. I think this cron service is built into VOLTTRON somehow.

1

There are 1 best solutions below

0
On

To have cron defined in a VOLTTRON context import it from volttron.platform.scheduling.

from volttron.platform.scheduling import cron

https://github.com/VOLTTRON/volttron/blob/main/volttron/platform/scheduling.py#L195