It's not great to indiscriminately be catching exceptions if it's avoidable, would be better to be more explicit about what you expect might fail here (key access? user.get_domain_membership()? user.save()?) and then let other things that fail unexpectedly fail