I have used this method a few times, so I scripted it in python.
Let me know what you think. I have ran it many times while "super-smack"ing my dev servers. It seems to work pretty darn well. Not a single query on the live server receives an error. They just pause for a few milliseconds (depending on the size of the table, ~8ms in most cases for me) while the write locks are held.
Please poke at it and let me know if I am missing anything!