A very brutal but simple and effective method is to bind() to a socket on localhost eg (127.0.0.1, 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 timedelay..
But this assumes you have an execution environment where this is acceptable. A sysadmin may have objections ;o) -- http://mail.python.org/mailman/listinfo/python-list