avoid script running twice

David Wahler dwahler at gmail.com
Mon Jun 18 16:55:28 EDT 2007


On 6/18/07, Robin Becker <robin at reportlab.com> wrote:
> Evan Klitzke wrote:
> > Another method that you can use is to open up a socket on some
> > predetermined port (presumably above 1024), and then have your program
> > try to connect to that port and "talk" to the other program to
> > determine whether or not to run (or whether to do some of the
> > remaining work, etc.).
> >
>
> that might work, but this runs on  someone's java solaris box with possible many
> connections going on. I doubt I'd be able to guarantee a particular port.

On platforms where it's supported -- I assume this includes Solaris --
you can use a UNIX-domain socket to avoid the risk of clashing with
network connections. It would be relatively straightforward to fall
back to a normal IP socket on Windows; just test for the existence of
socket.AF_UNIX.

-- David



More information about the Python-list mailing list