Ah!  That sounds great!  I will try using gluon's portalocker.

On Feb 18, 3:41 pm, mdipierro <[email protected]> wrote:
> I would use a file and lock the file when the process is running. You
> can check if the file is locked. When the process ends the file will
> be automatically unlocked.
>
> On Feb 18, 5:13 pm, Michael Toomim <[email protected]> wrote:
>
>
>
> > I'm running a background database processing task, and I only want to
> > have ONE task running so I don't have to worry about race conditions.
> > What is the best way to do this?
>
> > I run this task from a cron @reboot. It runs this script:
>
> > while True:
> >     time.sleep(10)
> >     process_queue()
>
> > I'm worried that I might accidentally run two web2py processes at the
> > same time, each starting a cron job, and then I'd have two running and
> > mess up my data. So I want this script to check to see if another one
> > is currently running, and if so, to give up.
>
> > I considered making an entry in a database like
> > "background_task_running = true", but how can I guarantee that it gets
> > set to false if my web2py crashes? I don't want to have to manually
> > reset that field all the time.
>
> > Is it best to see if this process is currently running on the machine,
> > with os.system('ps aux | grep background_work.py'), but this isn't
> > cross-platform, and won't work if the process is running on another
> > machine. Is there a way to check if another of these processes is
> > connected to the postgresql database?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to