From f35f06144fbdb8f63f0cc43c37c5ec284b6a9aec Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Mon, 21 Apr 2008 14:15:14 -0700 Subject: [PATCH] Remove some unnecessary calls to log.err and just print the error message instead. --- apt_p2p/CacheManager.py | 1 - apt_p2p/apt_p2p.py | 6 +++--- apt_p2p_Khashmir/DHT.py | 2 +- apt_p2p_Khashmir/actions.py | 3 +-- apt_p2p_Khashmir/khashmir.py | 6 ++---- apt_p2p_Khashmir/ktable.py | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/apt_p2p/CacheManager.py b/apt_p2p/CacheManager.py index 6801e02..e6a8408 100644 --- a/apt_p2p/CacheManager.py +++ b/apt_p2p/CacheManager.py @@ -307,7 +307,6 @@ class CacheManager: 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.""" diff --git a/apt_p2p/apt_p2p.py b/apt_p2p/apt_p2p.py index dfeb3e7..a771227 100644 --- a/apt_p2p/apt_p2p.py +++ b/apt_p2p/apt_p2p.py @@ -190,12 +190,12 @@ class AptP2P(protocol.Factory): 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): @@ -299,7 +299,7 @@ class AptP2P(protocol.Factory): """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 diff --git a/apt_p2p_Khashmir/DHT.py b/apt_p2p_Khashmir/DHT.py index d6ff2f1..7c4c7bd 100644 --- a/apt_p2p_Khashmir/DHT.py +++ b/apt_p2p_Khashmir/DHT.py @@ -451,7 +451,7 @@ class TestSimpleDHT(unittest.TestCase): 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, diff --git a/apt_p2p_Khashmir/actions.py b/apt_p2p_Khashmir/actions.py index fd5e1c1..0ac9647 100644 --- a/apt_p2p_Khashmir/actions.py +++ b/apt_p2p_Khashmir/actions.py @@ -198,8 +198,7 @@ class ActionBase: 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 diff --git a/apt_p2p_Khashmir/khashmir.py b/apt_p2p_Khashmir/khashmir.py index 7abed57..15237a2 100644 --- a/apt_p2p_Khashmir/khashmir.py +++ b/apt_p2p_Khashmir/khashmir.py @@ -200,8 +200,7 @@ class KhashmirBase(protocol.Factory): 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) @@ -240,8 +239,7 @@ class KhashmirBase(protocol.Factory): 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: diff --git a/apt_p2p_Khashmir/ktable.py b/apt_p2p_Khashmir/ktable.py index 499c4d8..f387898 100644 --- a/apt_p2p_Khashmir/ktable.py +++ b/apt_p2p_Khashmir/ktable.py @@ -239,7 +239,7 @@ class KTable: # 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 -- 2.39.2