After a couple of days, I found that my Python script had hung while connecting to the Unifi controller. I believe this is because there is no timeout in the requests() call, per the Requests documentation:
You can tell Requests to stop waiting for a response after a given number of seconds with the timeout parameter. Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely