我正在开发一个脚本,创建3个托尔实例使用干,从干教程“到俄罗斯与爱”。
def print_bootstrap_lines(line):
if "Bootstrapped " in line:
print(term.format(line, term.Color.BLUE))
def main():
SocksPort=9050
#print(str(SocksPort))
i=0
while i<2:
tor_process=stem.process.launch_tor_with_config(
config={
'SocksPort':str(SocksPort),
'ControlPort':str(SocksPort+1),
'ExitNodes':'{ru}',
'StrictNodes':'1',},
init_msg_handler=print_bootstrap_lines,
)
SocksPort=SocksPort+2
i=i+1创建第一个实例后,将打印返回错误:
OSError: Process terminated: No, it's still there. Exiting.发布于 2019-09-19 02:58:31
launch_tor_with_config()函数使用一个临时的新torrc文件启动tor,一旦tor实例被终止/停止,该文件就会被删除。但是我注意到有一个锁文件,就像您在中断Linux包管理器更新时所拥有的锁文件一样,但是它位于~/.tor/lck中,所以在启动新实例之前,请确保等待锁文件出现,然后从脚本中删除它,然后成功创建多个tor实例。
发布于 2020-03-15 04:15:19
只需为每个线程设置不同的"DataDirettory“。
self.tor_process = stem.process.launch_tor_with_config(
config={
'SocksPort':str(self.SocksPort),
'ControlPort':str(self.ControlPort),
'ExitNodes':self.ExitNodes,
'StrictNodes':self.StrictNodes,
'DataDirectory': path,
'Log': [
'NOTICE stdout',
'ERR file /tmp/tor_error_log',
],
},
#init_msg_handler=self.print_bootstrap_lines(),
)https://stackoverflow.com/questions/57955838
复制相似问题