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:

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

1 Answer 1


Nice timing, we just expanded our tutorials around this! For this you should use new_circuit() and attach_stream() rather than NEWNYM. For an example of doing this see...


  • Don't think there could be a better answer. Thanks!
    – Lizbeth
    Commented Jun 4, 2015 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .