On 8/22/07, Kevin J. Rice <[EMAIL PROTECTED]> wrote: > Hello! > > We're using Webware 0.9.1 and 0.9.4 in various places, so these questions > apply to both versions: > > We're wondering 2 things: > > 1. Can we find the current running request for each thread, when that > request started, and view the queue of requests not yet assigned to any > thread? > > 2. Can we automatically identify a request being processed for more than a > certain amount of time and terminate that request? This is a sort of a > timeout setting concept. >
I asked similar questions about 12 months ago so it might be worth having a look in the mailing list archive. In the end I concluded that terminating threads requires a Python extension that I did not want the trouble of integrating (but which may be included in a future release). As regards active requests, I have implemented a system that allows me to find out what my threads are doing. It works like this: In the base class for all my servlets, I include: class MyPage(PSPPage): def awake(self, transaction): PSPPage.awake(self, transaction) thread = threading.currentThread() thread.status = dict() self.setThreadStatus('awoke', time.asctime()) def sleep(self, trans): PSPPage.sleep(self, trans) self.setThreadStatus('awoke', 'asleep') def setThreadStatus(self, name, value): threading.currentThread().status[name] = value Any servlet can use self.setThreadStatus() to record tidbits about what it is doing. Then I have a PSP servlet that displays the status for all threads: <[EMAIL PROTECTED] extends="WebKit.Page"%> <[EMAIL PROTECTED] method="writeContent"%> <[EMAIL PROTECTED] imports="cgi, WebKit.ThreadedAppServer, threading"%> <% server = WebKit.ThreadedAppServer.server %> Active threads according to server: <%=server.activeThreadCount()%> <% allThreads = server._threadPool notProcessing = 0 curThread = threading.currentThread() threads = filter(lambda t: t != curThread, allThreads) for thread in threads: %> <%if thread.processing:%> <% status = thread.__dict__.get('status', None) if status is None:%> <p>No status information available.</p> <%end%> <%else:%> <table> <%for key, value in status.items():%> <tr><td><%=key%></td><td><%=cgi.escape(str(value))%></td></tr> <%end%> </table> <%end%> <%end%> <%else: notProcessing = notProcessing + 1%> <%end%> <p>Not processing: <%=notProcessing%> +1 for thread servicing this request</p> ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss