We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在 sender.py 中的 run() 里面如果 subprocess.getstatusoutput(DIAL_BASH) 执行提前结束,就会陷入无限拨号的问题。比如 subprocess.getstatusoutput(DIAL_BASH) 执行完了,拨号还没成功,还没获取到IP地址,需要等个10秒才获取到IP地址。此时提前进入 self.extract_ip() 获取IP,就会获取不到,ip 这个变量为空,进入 else 语句,马上重新执行 self.run() 重新拨号。。
建议或者在 self.extract_ip() 里面加入一个 while 等待时间 ,比如每 while 60秒,每检查一次就减1,然后sleep 1秒。有个60秒等待时间,再返回IP,或许会比较好。比如这样:
def extract_ip(self): """ 获取本机IP :param ifname: 网卡名称 :return: """ WAIT_TIME = 60 while WAIT_TIME: (status, output) = subprocess.getstatusoutput('ifconfig') if not status == 0: return pattern = re.compile(DIAL_IFNAME + '.*?inet.*?(\d+\.\d+\.\d+\.\d+).*?netmask', re.S) result = re.search(pattern, output) if result: # 返回拨号后的 IP 地址 return result.group(1) WAIT_TIME -= 1 time.sleep(1)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在 sender.py 中的 run() 里面如果 subprocess.getstatusoutput(DIAL_BASH) 执行提前结束,就会陷入无限拨号的问题。比如 subprocess.getstatusoutput(DIAL_BASH) 执行完了,拨号还没成功,还没获取到IP地址,需要等个10秒才获取到IP地址。此时提前进入 self.extract_ip() 获取IP,就会获取不到,ip 这个变量为空,进入 else 语句,马上重新执行 self.run() 重新拨号。。
建议或者在 self.extract_ip() 里面加入一个 while 等待时间 ,比如每 while 60秒,每检查一次就减1,然后sleep 1秒。有个60秒等待时间,再返回IP,或许会比较好。比如这样:
The text was updated successfully, but these errors were encountered: