Making sure script only runs once instance at a time.

MaR Maria.Reinhammar at
Fri Sep 29 13:59:41 CEST 2006

A very brutal but simple and effective method is to bind() to a socket
on localhost eg (, 4711), listen() but never accept().
Any other process trying to to bind() on the same port will fail..
When the process dies, the port is released automatically, pending som

But this assumes you have an execution environment where this is
acceptable. A sysadmin may have objections ;o)

More information about the Python-list mailing list