I've mused that a solid "delayed clipboard clear" feature would do some kind of atomic Compare-And-Swap, because otherwise the originating program could conceivably blow away something it didn't put there.
The clipboard lib you're using just spawns xclip (or xsel) on Unix. xclip has a -loops argument that is the maximum number of pastes. So you could just spawn:
xclip -loops 1 -in -selection clipboard
And the password would be available to paste exactly once. Unfortunately I don't think xsel has any such option.There are clipboard manager apps that could grab the paste immediately and persist it, but I'm not sure how common they are or if they are default anywhere.