The last example on the page it seems like you're just "really hoping" that the next stream to open is the one you want to map onto the new circuit, or am I missing something?
Hi meejah. Yup, you're right. To keep things simple it's just attaching the next stream. If you were using your tor client for other things too this wouldn't be a safe assumption and the caller would need additional checks that it's the stream they want.
Python's builtin connection modules really suck, hence our need for SocksiPy or PycURL. Maybe python3's asyncio (the builtin which seems intended to replace twisted) has better options. I certainly wouldn't be surprised if what Twisted provides is better than the builtins we had on python 2.7.