I have a Python script that is configured to connect to 4 different onion services (call them a, b, c, d), and return a value on a page. I'd like to ensure that I create separate circuits to connect to each so that circuit-1 only connects to a and is never used for b,c, or d.
I'm using Stem and this is an example they provide for issuing a NEWNYM command to the control protocol and create new circuits.
with Controller.from_port(port = 9150) as controller: controller.authenticate() controller.signal(Signal.NEWNYM)
I understand this to flush all circuits and re-build new ones.
Is there a better way to specifically control which circuit a Python HTTP request takes? I'd like concurrently make these requests from 4 different circuits at the same time. Basically:
- create new circuit
- assign circuit to a.onion
- issue request
- destroy circuit
- repeat for b, c, and d.onion