Which stem python code would you suggest to determine whether tor is operational (bootstrapped at 100%) or not?

  • As a client or as a relay?
    – cacahuatl
    Feb 20, 2017 at 22:44
  • As a client, I have edited the post.
    – user123456
    Feb 21, 2017 at 9:44

1 Answer 1


You need to query the client bootstrap status. It's done - as it's said in control protocol spec like this:

telnet 9051
Connected to
Escape character is '^]'.
AUTHENTICATE "cleartextpassword"
250 OK
GETINFO status/bootstrap-phase
250-status/bootstrap-phase=NOTICE BOOTSTRAP PROGRESS=100 TAG=done SUMMARY="Done"
250 OK
250 closing connection
Connection closed by foreign host.

You need - if using Stem - a Controller class, and the python code doing exactly this will be:

import stem
import stem.connection
from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
    controller.authenticate(password = 'cleartextpassword')

if(response.find('SUMMARY="Done"') > 0):
    print "bootstrapped OK"
    print "Bootstrap not finished: " + response

Have a good day!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.