@@ -158,14 +158,12 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
158158 if tor_overrides :
159159 tor_options .update (tor_overrides )
160160
161- tor_config = txtorcon .TorConfig ()
162-
163- # Update Tor config options from dictionary
164- for key , value in tor_options .items ():
165- setattr (tor_config , key , value )
166-
167161 if launch_tor :
168162 log .info ("Spawning a new Tor instance." )
163+ tor_config = txtorcon .TorConfig ()
164+ # Update tor config options from dictionary
165+ for key , value in tor_options .items ():
166+ setattr (tor_config , key , value )
169167 # TODO: Pass in data_dir directory so consensus can be cached
170168 # Launch tor with config, in order to don't get CONF_CHANGED when
171169 # updating options that can't be changed while tor is running.
@@ -179,7 +177,8 @@ def connect_to_tor(launch_tor, circuit_build_timeout, control_port=None,
179177 tor = yield txtorcon .connect (reactor , endpoint )
180178 # TODO: check whether CONF_CHANGED will happen here or not because
181179 # we get the state later
182- tor .config = tor_config
180+ for key , value in tor_options .items ():
181+ setattr (tor .config , key , value )
183182 tor .config .save ()
184183
185184 wait_for_consensus = options_need_new_consensus (tor_config , tor_options )
0 commit comments