Tor hangs because stem isn't reading its stdout
In order to do careful monitoring of an experiment I'm running over Tor, I wrote a bridge controller that allocates an ORPort to each client as it checks in. Clients come and go; there are only ever about 20 of them at a time, but stale connections don't get cleaned up very quickly, so I wind up having to manage 100+ ORPorts.
It appears that at some critical number of ORPorts -- the logs suggest 160 -- Tor gets stuck halfway through the process of reinitializing itself; crucially, it doesn't ever respond to the SETCONF message, and it also stops processing all other input.
I'm not sure whether this is supposed to be a supported configuration -- it's certainly an abnormal configuration -- but it seems to me that if there is an upper limit, SETCONF should fail when you hit it, rather than having the relay just stop working.
Debug logs attached.