def register_cleanup_lock_removal(lock_path, register=atexit.register):
pid = os.getpid()<EOL>def cleanup_on_exit(lock_path=lock_path, original_pid=pid):<EOL><INDENT>current_pid = os.getpid()<EOL>if current_pid != original_pid:<EOL><INDENT>return<EOL><DEDENT>try:<EOL><INDENT>lock_path.unlink()<EOL><DEDENT>except (OSError, IOError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return register(cleanup_on_exit)<EOL>
registers a cleanup function for removing a lock, by default on atexit