本文整理汇总了Python中mixminion.Common.LOG.error_exc方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.error_exc方法的具体用法?Python LOG.error_exc怎么用?Python LOG.error_exc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mixminion.Common.LOG
的用法示例。
在下文中一共展示了LOG.error_exc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import error_exc [as 别名]
def run(self):
"""Thread body: pull questions from the DNS thread queue and
answer them."""
queue = self.dnscache.queue
_lookupDone = self.dnscache._lookupDone
_adjBusyThreads = self.dnscache._adjBusyThreads
_adjLiveThreads = self.dnscache._adjLiveThreads
try:
_adjLiveThreads(1)
try:
while 1:
# Get a question from the queue, but don't wait more than
# MAX_THREAD_IDLE seconds
hostname = queue.get(timeout=MAX_THREAD_IDLE)
# If the question is None, shutdown.
if hostname is None:
return
# Else, resolve the IP and send the answer to the dnscache
_adjBusyThreads(1)
result = mixminion.NetUtils.getIP(hostname)
_lookupDone(hostname, result)
_adjBusyThreads(-1)
except QueueEmpty:
LOG.debug("DNS thread shutting down: idle for %s seconds.",
MAX_THREAD_IDLE)
except:
LOG.error_exc(sys.exc_info(),
"Exception in DNS thread; shutting down.")
finally:
_adjLiveThreads(-1)
示例2: deliveryFailed
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import error_exc [as 别名]
def deliveryFailed(self, handle, retriable=0, now=None):
assert self.retrySchedule is not None
if now is None:
now = time.time()
self._lock.acquire()
try:
try:
mState = self.store.getMetadata(handle)
except KeyError:
mState = None
except CorruptedFile:
mState = None
if mState is None:
# This should never happen
LOG.error_exc(sys.exc_info(),
"Handle %s had no state; removing", handle)
self.removeMessage(handle)
return
elif not mState.isPending():
LOG.error("Handle %s was not pending", handle)
return
last = mState.pending
mState.setNonPending()
if not retriable:
LOG.trace(" (Giving up on %s)", handle)
self.removeMessage(handle)
aState = self._getAddressState(mState.address, now)
aState.failed(attempt=last,now=now)
aState.setNextAttempt(self.retrySchedule,now=now)
self.addressStateDB[str(aState.address)] = aState # flush to db.
finally:
self._lock.release()
示例3: run
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import error_exc [as 别名]
def run(self):
"""Internal: main body of processing thread."""
try:
while 1:
job = self.mqueue.get()
job()
except ProcessingThread._Shutdown:
LOG.info("Shutting down %s",self.threadName)
return
except:
LOG.error_exc(sys.exc_info(),
"Exception in %s; shutting down thread.",
self.threadName)
示例4: publish
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import error_exc [as 别名]
def publish(self, url):
"""Try to publish this descriptor to a given directory URL. Returns
'accept' if the publication was successful, 'reject' if the
server refused to accept the descriptor, and 'error' if
publication failed for some other reason."""
fname = self.getDescriptorFileName()
descriptor = readFile(fname)
fields = urllib.urlencode({"desc" : descriptor})
f = None
try:
try:
f = urllib2.urlopen(url, fields)
info = f.info()
reply = f.read()
except IOError, e:
LOG.error("Error while publishing server descriptor: %s",e)
return 'error'
except:
LOG.error_exc(sys.exc_info(),
"Error publishing server descriptor")
return 'error'
示例5: publish
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import error_exc [as 别名]
def publish(self, url):
"""Try to publish this descriptor to a given directory URL. Returns
'accept' if the publication was successful, 'reject' if the
server refused to accept the descriptor, and 'error' if
publication failed for some other reason."""
fname = self.getDescriptorFileName()
descriptor = readFile(fname)
fields = urllib.urlencode({"desc" : descriptor})
f = None
try:
try:
#############################################
# some python versions verify certificates
# anemone.mooo.com uses a self-signed cert
# this workaround is not a problem because
# the directory information is already signed
# (although as Zax says, it is certainly a
# kludge ;)
if sys.version_info >= (2,7,9):
ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
f = urllib2.urlopen(url, fields, context=ctx)
else:
f = urllib2.urlopen(url, fields)
#############################################
#f = urllib2.urlopen(url, fields)
info = f.info()
reply = f.read()
except IOError, e:
LOG.error("Error while publishing server descriptor: %s",e)
return 'error'
except:
LOG.error_exc(sys.exc_info(),
"Error publishing server descriptor")
return 'error'