From c73953d94aa391a4170691c8e85fa8a123b24221 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 14 Apr 2020 08:40:48 -0400 Subject: [PATCH 1/5] Capture and report Foolscap Tub Listener creation stack on error --- src/allmydata/test/__init__.py | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/allmydata/test/__init__.py b/src/allmydata/test/__init__.py index 804d37935..af55be353 100644 --- a/src/allmydata/test/__init__.py +++ b/src/allmydata/test/__init__.py @@ -52,6 +52,44 @@ def _configure_hypothesis(): settings.load_profile(profile_name) _configure_hypothesis() +def logging_for_pb_listener(): + """ + Make Foolscap listen error reports include Listener creation stack + information. + """ + from traceback import extract_stack, format_list + from foolscap.pb import Listener + from twisted.python.log import err + from twisted.application import service + + original__init__ = Listener.__init__ + def _listener__init__(self, *a, **kw): + original__init__(self, *a, **kw) + # Capture the stack here, where Listener is instantiated. This is + # likely to explain what code is responsible for this Listener, useful + # information to have when the Listener eventually fails to listen. + self._creation_stack = extract_stack() + + # Override the Foolscap implementation with one that has an errback + def _listener_startService(self): + service.Service.startService(self) + d = self._ep.listen(self) + def _listening(lp): + self._lp = lp + d.addCallbacks( + _listening, + # Make sure that this listen failure is reported promptly and with + # the creation stack. + err, + errbackArgs=( + "Listener created at {}".format( + "".join(format_list(self._creation_stack)), + ), + ), + ) + Listener.__init__ = _listener__init__ + Listener.startService = _listener_startService +logging_for_pb_listener() import sys if sys.platform == "win32": From 47bef6038f8213fde691a4b9e8ee7861d9747fd5 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 14 Apr 2020 08:41:10 -0400 Subject: [PATCH 2/5] news fragment --- newsfragments/3302.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3302.minor diff --git a/newsfragments/3302.minor b/newsfragments/3302.minor new file mode 100644 index 000000000..e69de29bb From 72ca4e8c53191aabe6599ac72c113106552f1b8f Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Wed, 15 Apr 2020 08:54:50 -0400 Subject: [PATCH 3/5] move the imports --- src/allmydata/test/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/allmydata/test/__init__.py b/src/allmydata/test/__init__.py index af55be353..fb62e438f 100644 --- a/src/allmydata/test/__init__.py +++ b/src/allmydata/test/__init__.py @@ -1,3 +1,8 @@ +from traceback import extract_stack, format_list +from foolscap.pb import Listener +from twisted.python.log import err +from twisted.application import service + from foolscap.logging.incident import IncidentQualifier class NonQualifier(IncidentQualifier, object): @@ -57,11 +62,6 @@ def logging_for_pb_listener(): Make Foolscap listen error reports include Listener creation stack information. """ - from traceback import extract_stack, format_list - from foolscap.pb import Listener - from twisted.python.log import err - from twisted.application import service - original__init__ = Listener.__init__ def _listener__init__(self, *a, **kw): original__init__(self, *a, **kw) From d4d8ce4e13d6f5b9103c18c1da722fe26f0f0bde Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Wed, 15 Apr 2020 08:55:00 -0400 Subject: [PATCH 4/5] missing front matter --- src/allmydata/test/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/allmydata/test/__init__.py b/src/allmydata/test/__init__.py index fb62e438f..60d9b87d6 100644 --- a/src/allmydata/test/__init__.py +++ b/src/allmydata/test/__init__.py @@ -1,3 +1,18 @@ +# Tahoe-LAFS -- secure, distributed storage grid +# +# Copyright © 2020 The Tahoe-LAFS Software Foundation +# +# This file is part of Tahoe-LAFS. +# +# See the docs/about.rst file for licensing information. + +""" +Some setup that should apply across the entire test suite. + +Rather than defining interesting APIs for other code to use, this just causes +some side-effects which make things better when the test suite runs. +""" + from traceback import extract_stack, format_list from foolscap.pb import Listener from twisted.python.log import err From 71aa17ab0bbb3371f43c205aeda8092867c300b2 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Wed, 15 Apr 2020 09:07:23 -0400 Subject: [PATCH 5/5] I assume it's utf-8 --- src/allmydata/test/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/allmydata/test/__init__.py b/src/allmydata/test/__init__.py index 60d9b87d6..abbde919f 100644 --- a/src/allmydata/test/__init__.py +++ b/src/allmydata/test/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Tahoe-LAFS -- secure, distributed storage grid # # Copyright © 2020 The Tahoe-LAFS Software Foundation