On Jul 28, 2009, at 7:19 PM, Christian Heimes wrote:
John D Giotta schrieb:
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?
Since you are talking about crontab I assume that you are on an os
that
supports pthreads. You problem can easily be solved with a named
semaphore (see sem_open(3) and sem_overview(7)). Unfortunately Python
doesn't expose named semaphores. The multiprocessing library uses
named
semaphores but you can't set the name yourself.
You have to write your own C wrapper or search on pypi and through
Google. If you are going to write your own semaphore I highly
recommend
Cython.
My POSIX IPC extension permits manipulation of interprocess semaphores:
http://semanchuk.com/philip/posix_ipc/
There's also one for SysV IPC:
http://semanchuk.com/philip/sysv_ipc/
Enjoy
P
--
http://mail.python.org/mailman/listinfo/python-list