[Checkins] SVN: z3c.deadlockdebugger/trunk/ Ported the Zope 2-based
code from the DeadlockDebugger and set up a view.
Malthe Borch
mborch at gmail.com
Thu Feb 14 05:27:13 EST 2008
Log message for revision 83823:
Ported the Zope 2-based code from the DeadlockDebugger and set up a view.
Changed:
A z3c.deadlockdebugger/trunk/README.txt
U z3c.deadlockdebugger/trunk/setup.py
A z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/configure.zcml
A z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/threads.py
-=-
Added: z3c.deadlockdebugger/trunk/README.txt
===================================================================
--- z3c.deadlockdebugger/trunk/README.txt (rev 0)
+++ z3c.deadlockdebugger/trunk/README.txt 2008-02-14 10:27:12 UTC (rev 83823)
@@ -0,0 +1,20 @@
+Overview
+--------
+
+The z3c.deadlockdebugger package provides a thread debugger.
+
+Usage:
+
+ /debug_threads
+
+ (requires the 'zope.ManageApplication' permission)
+
+Caution: You should not use this package in production.
+
+
+Credits
+-------
+
+This package was put together by Malthe Borch <mborch at gmail.com>. It's
+based on the Zope 2 product ``DeadlockDebugger`` written by Florent
+Guillaume.
Modified: z3c.deadlockdebugger/trunk/setup.py
===================================================================
--- z3c.deadlockdebugger/trunk/setup.py 2008-02-14 10:17:21 UTC (rev 83822)
+++ z3c.deadlockdebugger/trunk/setup.py 2008-02-14 10:27:12 UTC (rev 83823)
@@ -5,10 +5,8 @@
setup(name='z3c.deadlockdebugger',
version=version,
- description="",
- long_description="""\
-""",
- # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+ description="A thread debugger.",
+ long_description=open("README.txt").read(),
classifiers=[
"Framework :: Plone",
"Framework :: Zope2",
@@ -17,8 +15,8 @@
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='',
- author='',
- author_email='',
+ author='Zope Corporation and Contributors',
+ author_email='zope3-dev at zope.org',
url='',
license='ZPL',
packages=find_packages(exclude=['ez_setup']),
@@ -27,6 +25,8 @@
zip_safe=False,
install_requires=[
'setuptools',
+ 'zope.publisher',
+ 'threadframe',
# -*- Extra requirements: -*-
],
entry_points="""
Added: z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/configure.zcml
===================================================================
--- z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/configure.zcml (rev 0)
+++ z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/configure.zcml 2008-02-14 10:27:12 UTC (rev 83823)
@@ -0,0 +1,11 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <browser:page
+ name="debug_threads"
+ for="*"
+ permission="zope.ManageApplication"
+ class=".threads.View"
+ />
+
+</configure>
Added: z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/threads.py
===================================================================
--- z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/threads.py (rev 0)
+++ z3c.deadlockdebugger/trunk/z3c/deadlockdebugger/threads.py 2008-02-14 10:27:12 UTC (rev 83823)
@@ -0,0 +1,53 @@
+from zope.publisher.browser import BrowserView
+
+import thread
+import threadframe
+import traceback
+import time
+from cStringIO import StringIO
+
+def dump_threads():
+ """Dump running threads
+
+ Returns a string with the tracebacks.
+ """
+
+ frames = threadframe.dict()
+ this_thread_id = thread.get_ident()
+ now = time.strftime("%Y-%m-%d %H:%M:%S")
+ res = ["Threads traceback dump at %s\n" % now]
+ for thread_id, frame in frames.iteritems():
+ if thread_id == this_thread_id:
+ continue
+
+ # Find request in frame
+ reqinfo = ''
+ f = frame
+ while f is not None:
+ co = f.f_code
+ if (co.co_name == 'publish' and
+ co.co_filename.endswith('/ZPublisher/Publish.py')):
+ request = f.f_locals.get('request')
+ if request is not None:
+ reqinfo = (request.get('REQUEST_METHOD', '') + ' ' +
+ request.get('PATH_INFO', ''))
+ qs = request.get('QUERY_STRING')
+ if qs:
+ reqinfo += '?'+qs
+ break
+ f = f.f_back
+ if reqinfo:
+ reqinfo = " (%s)" % reqinfo
+
+ output = StringIO()
+ traceback.print_stack(frame, file=output)
+ res.append("Thread %s%s:\n%s" %
+ (thread_id, reqinfo, output.getvalue()))
+
+ frames = None
+ res.append("End of dump")
+ return '\n'.join(res)
+
+class View(BrowserView):
+ def __call__(self):
+ return dump_threads()
More information about the Checkins
mailing list