I'd like to use a cron job running with @reboot to process a queue.
What I want in the queue are the names of modules & functions to call,
and a time to call them.
Here's the catch - I'd like the functions in the queue to be in a
controller.
Here's where I execute (next is the row with the task queue entry)
mod = sys.modules[next.module_name]
if next.kwargs:
args = ast.literal_eval(next.kwargs)
getattr(mod, next.method_name)(**args)
else:
getattr(mod, next.method_name)()
and here's where I tried to trigger running my controller method:
db.task_queue.insert(module_name=__name__, method_name='do_poll',
run_time = run_time)
The problem is that __name__ is always '__main__' and getattr always
fails to find the method.
I need controller methods so they can in turn call module methods and
pass the db variable.
Any hints?