def GetPage(self,url):
try:
fp = urllib2.urlopen(url)
result = fp.read()
except Exception, e:
self.logger.error(
'url %s is unreachable. Exception %s %s' %
(url, e.__class__.__name__, e))
result=None
fp.close()
return result
多个线程有可能同时执行这段代码,GetPage是一个对象里的方法
有时会返回unboundlocalerror local variable fp referenced before assignment
在线等高人赐教
try:
fp = urllib2.urlopen(url)
result = fp.read()
except Exception, e:
self.logger.error(
'url %s is unreachable. Exception %s %s' %
(url, e.__class__.__name__, e))
result=None
fp.close()
return result
多个线程有可能同时执行这段代码,GetPage是一个对象里的方法
有时会返回unboundlocalerror local variable fp referenced before assignment
在线等高人赐教