Django连apache后ping IP地址不通时锁死,求高人指点
django吧
全部回复
仅看楼主
level 1
Ubuntu12.04, apache2, django1.6.所有views.py里的函数均能在相关页面模版下正常执行.
但是每次函数执行到a=commands.getstatusoutput('ping -w 1 -c 1 '+IP_ADD)时,只有IP可以ping通才有返回, 当使用1.1.1.1等不通IP时, 页面就死在那不动了, 没有任何返回和报错, 就是小圆圈不停的转.
用django自带的http server没问题, 运行其它cmd命令也没问题不知如何debug, 求高人指点, 感激不尽.
2014年04月25日 10点04分 1
level 1
def try_server(ip):
try:
action='ping -w 1 -c 1 '+ip
ping_result=commands.getstatusoutput(action)
if ping_result[0]==0:
return True
else:
return False
except:
return False
当IP不通的时候, 根本就不返回, 百思不得其解
2014年04月25日 10点04分 2
level 8
可能要考虑使用异步机制
2014年04月30日 12点04分 3
1