I have some python that talks to a tor daemon, here it tells the daemon to shut down.
from stem import Signal
from stem.control import Controller
def shutDownTor():
with Controller.from_port(port=portNum) as controller:
controller.signal(Signal.SHUTDOWN)
I'm using a with
statement because the code I'm stealing from learning from does so too. The code works fine, but I'm wondering if there is any point to using the with
statement.
I know that when you use with
to open files it makes sure the file closes even if there's an Exception
or interrupt. But in this case it seems like all with
is doing is adding an un-necessary tab. The variable controller
is even left inside the namespace.