I'm writing a Django app that uses a management command to pull data from various sources. The plan is to run this command hourly with cron, and also have it run on user command from a view (i.e. when they add a new item that needs data, I don't want them to wait for the next hour to roll around to see results). The question is:
How can I set up this command such that if it is already currently running, it won't execute? Is there some place where I can stash a variable that can be checked by the script before execution? My current best idea is to have the command monitor stdout for a while to make sure nothing else is executing, but that seems like a hack at best. This is the only task that will be running in the background.
I'm basically trying to avoid using Celery here.