One Weird Trick to avoid waiting ~forever to acquire exclusive locks when making Postgres schema changes (e.g. attaching/detaching partitions, which is where I usually need this):
1. begin a transaction;
2. rename your table (or the entire schema) to some temporary/anonymous name;
3. perform the DDL operation;
4. rename your table/schema back;
5. commit the transaction.
I have no idea why this works, but it does!