hash = HashObject()
df = hash.hashInThread(file)
df.addBoth(self._doneHashing, file, walker)
- df.addErrback(log.err)
def _doneHashing(self, result, file, walker):
"""If successful, add the hashed file to the DB and inform the main program."""
findDefer.addCallbacks(self.findHash_done, self.findHash_error,
callbackArgs=(req, url, orig_resp, d),
errbackArgs=(req, url, orig_resp, d))
- findDefer.addErrback(log.err)
return d
def findHash_error(self, failure, req, url, orig_resp, d):
"""Process the error in hash lookup by returning an empty L{HashObject}."""
- log.err(failure)
+ log.msg('Hash lookup for %s resulted in an error: %s' %
+ (url, failure.getErrorMessage()))
self.findHash_done(HashObject(), req, url, orig_resp, d)
def findHash_done(self, hash, req, url, orig_resp, d):
"""Check the returned response to be sure it is valid."""
if isinstance(resp, failure.Failure):
log.msg('Got error trying to get cached file')
- log.err()
+ log.err(resp)
# Try the next possible location
self.getCachedFile(hash, req, url, d, locations)
return
class TestMultiDHT(unittest.TestCase):
"""More complicated 20-node tests for the DHT."""
- timeout = 80
+ timeout = 100
num = 20
DHT_DEFAULTS = {'PORT': 9977,
'CHECKPOINT_INTERVAL': 300, 'CONCURRENT_REQS': 4,
def actionFailed(self, err, node, expected_results, df):
"""Receive an error from a remote node."""
- log.msg("action %s failed (%s) %s/%s" % (self.action, self.config['PORT'], node.host, node.port))
- log.err(err)
+ log.msg("action %s failed on %s/%s: %s" % (self.action, node.host, node.port, err.getErrorMessage()))
self.caller.table.nodeFailed(node)
self.outstanding -= 1
self.outstanding_results -= expected_results
def _staleNodeHandler(err, oldnode = old, newnode = node, self = self, start = datetime.now()):
"""The pinged node never responded, so replace it."""
- log.msg("ping failed (%s) %s/%s" % (self.config['PORT'], oldnode.host, oldnode.port))
- log.err(err)
+ log.msg("action ping failed on %s/%s: %s" % (oldnode.host, oldnode.port, err.getErrorMessage()))
self.stats.completedAction('ping', start)
self.table.replaceStaleNode(oldnode, newnode)
def _defaultPong(err, node=node, self=self, callback=callback, errback=errback, start = datetime.now()):
"""Error occurred, fail node and errback or callback with error."""
- log.msg("join failed (%s) %s/%s" % (self.config['PORT'], node.host, node.port))
- log.err(err)
+ log.msg("action join failed on %s/%s: %s" % (node.host, node.port, err.getErrorMessage()))
self.stats.completedAction('join', start)
self.table.nodeFailed(node)
if errback:
# Make sure our table isn't FULL, this is really unlikely
if len(self.buckets) >= (khash.HASH_LENGTH*8):
- log.err("Hash Table is FULL! Increase K!")
+ log.err(RuntimeError("Hash Table is FULL! Increase K!"))
return
# This bucket is full and contains our node, split the bucket