[Zope-dev] Tracking long-running requests
Dieter Maurer
dieter at handshake.de
Wed Dec 7 16:13:36 EST 2005
Chris Withers wrote at 2005-12-7 10:01 +0000:
>> You err: I do want to see them in the logfile and
>> I stole Florents idea to use "threadframe" (in his "DeadlockDebugger")
>> to include a traceback for long running requests in the logfile.
>> This way, it is
>> easy not only to identify long running requests but also to
>> get hints where they are spending their time...
>>
>>
>> You will not believe how fast this has eliminated our remaining
>> long running requests and especially to track down
>> a non deterministic rarely occuring apparent deadlock situation...
>
>Is this code available anywhere?
No.
It relies on "ZPublisher.Publish" hacking
in order to learn when requests get started and finished.
Based on these "events", the set of currently worked
on requests is maintained. An independent thread
periodically monitors this set, identifies long
running requests and calls configured handlers for them.
The traceback logging handler looks like:
from threadframe import dict as getFrames
def handler(req, handlerState, globalState):
threadId = req.threadId
LOG('RequestMonitor.DumpTrace', WARNING, 'Long running request',
'Request %s "%s" running in thread %s since %ss\n%s' % (
req.id,
req.info,
threadId,
handlerState.monitorTime - req.startTime,
''.join(formatStack(getFrames()[threadId])),
)
)
Thus, for general availability, we would need "start_publishing"
and "finish_publishing" hooks in "ZPublisher".
And, as we speak about replacing Zope2's ZPublisher
by Zope3's Publisher, the old Zope2 ZPublisher will
probably not grow such hooks any more -- but hopefully,
the Zope3 Publisher will signal corresponding events.
>
>cheers,
>
>Chris
>
>--
>Simplistix - Content Management, Zope & Python Consulting
> - http://www.simplistix.co.uk
>
>
--
Dieter
More information about the Zope-Dev
mailing list