Semaphore Techniques

Piet van Oostrum piet at cs.uu.nl
Wed Jul 29 10:14:45 EDT 2009


>>>>> Carl Banks <pavlovevidence at gmail.com> (CB) wrote:

>CB> On Jul 28, 3:15 pm, John D Giotta <jdgio... at gmail.com> wrote:
>>> I'm looking to run a process with a limit of 3 instances, but each
>>> execution is over a crontab interval. I've been investigating the
>>> threading module and using daemons to limit active thread objects, but
>>> I'm not very successful at grasping the documentation.
>>> 
>>> Is it possible to do what I'm trying to do and if so anyone know of a
>>> useful example to get started?

>CB> It seems like you want to limit the number of processes to three; the
>CB> threading module won't help you there because it deals with threads
>CB> within a single process.

>CB> What I'd do is to simply run the system ps to see how many processes
>CB> are running (ps is pretty versatile on most systems and can find
>CB> specifically targeted processes like you program), and exit if there
>CB> are already three.

That will surely run into some race conditions. If the limit of 3
processes is soft then that wouldn't be a big deal, however.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list