Semaphore Techniques

Carl Banks pavlovevidence at gmail.com
Wed Jul 29 18:55:26 EDT 2009


On Jul 29, 7:14 am, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>>>> Carl Banks <pavlovevide... 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.

What, the OS might not have gotten around to update the process table
to include a process started minutes ago?  (He said he was starting
the processes over crontab intervals, not that he communicated what he
wanted well.)


Carl Banks



More information about the Python-list mailing list