commit 8c61fc85a51f9acb65e9fed15bb079a8fad47636 Author: Damian Johnson atagar@torproject.org Date: Fri Jan 18 10:52:13 2019 -0800
Revert "Include the originating stacktrace in stem.descriptor.remote exceptions"
Unfortunately in this case the cure is worse than the disease. When dannenberg went down this caused stacktraces in DocTor's emails which gives the impression the service is having problems...
ERROR: Unable to retrieve the consensus from dannenberg (http://193.23.244.244:80/tor/status-vote/current/consensus): <urlopen error <urlopen error [Errno 111] Connection refused>
Original traceback: File "/srv/doctor.torproject.org/doctor/stem/descriptor/remote.py", line 594, in _download_descriptors self.content, self.reply_headers = _download_from_dirport(self.download_url, self.compression, timeout) File "/srv/doctor.torproject.org/doctor/stem/descriptor/remote.py", line 1043, in _download_from_dirport timeout = timeout, File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 429, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 447, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1228, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open raise URLError(err) URLError: <urlopen error [Errno 111] Connection refused>
I'm kinda torn on this change. On one hand it's usful information for unusual errors, but on the other it's troubling looking bloat for mundane things like this.
Encoding a stacktrace within an encepiton message was definitely an icky hack so simply reverting this for now. Most likely we'll simply need to live without underlying stacktraces until we drop python 2.x support.
This reverts commit cc43a6ca90e3943a542258b2b4d8466ae9a4ac36. --- stem/descriptor/remote.py | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-)
diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py index 9ccfaced..9eb639ad 100644 --- a/stem/descriptor/remote.py +++ b/stem/descriptor/remote.py @@ -97,7 +97,6 @@ import random import sys import threading import time -import traceback import zlib
import stem @@ -467,13 +466,6 @@ class Query(object): Blocks until our request is complete then provides the descriptors. If we haven't yet started our request then this does so.
- .. versionchanged:: 1.8.0 - Overwriting exceptions to include the originating traceback. - - In Stem 2.x (when we no longer need Python 2.x compatibility) this will - revert back to re-raising the originating exception, but with its - stacktrace preserved. - :param bool suppress: avoids raising exceptions if **True**
:returns: list for the requested :class:`~stem.descriptor.__init__.Descriptor` instances @@ -483,7 +475,6 @@ class Query(object): **False**...
* **ValueError** if the descriptor contents is malformed - * **stem.ProtocolError** if unable to parse an ORPort response * **socket.timeout** if our request timed out * **urllib2.URLError** for most request failures
@@ -502,27 +493,7 @@ class Query(object): if suppress: return
- # TODO: Unfortunately the proper way to retain a stacktrace differs - # between python 2.x and 3.x in a syntactic way... - # - # Python 2.x - # - # raise exc_type, exc_value, exc_traceback - # - # Python 3.x - # - # raise WrapperException('foo') from exc_value - # - # Because this is syntactic we cannot do an 'if python2, else python3' - # for this. As such re-encoding the stacktrace as part of the message. - # - # When we drop python 2.x support we should replace this with the - # 'raise from' option above. - - exc_type, exc_value, exc_traceback = self._error_attr - stacktrace = 'Original traceback:\n' + ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)[1:]) - - raise exc_type(str(exc_value) + '\n\n' + stacktrace) + raise self.error else: if self.content is None: if suppress: @@ -554,7 +525,6 @@ class Query(object): yield desc except ValueError as exc: self.error = exc # encountered a parsing error - self._error_attr = sys.exc_info()
if suppress: return @@ -609,7 +579,6 @@ class Query(object): else: log.debug("Unable to download descriptors from '%s': %s" % (self.download_url, exc)) self.error = exc - self._error_attr = sys.exc_info() finally: self.is_done = True