Ñò ô†³Kc @sdZddkZddkZddkZddkZddklZddklZddk l Z ddk l Z l Z ddklZlZedd d ƒZd efd „ƒYZd „ZdgZd„Zd„Zd„Zed„Zeie_dd„ZdS(sv Watches the key ``paste.httpserver.thread_pool`` to see how many threads there are and report on any wedged threads. iÿÿÿÿN(tStringIO(t get_ident(thttpexceptions(t construct_urltparse_formvars(t HTMLTemplatetbunchsv {{title}}

{{title}}

{{if kill_thread_id}}
Thread {{kill_thread_id}} killed
{{endif}}
Pool size: {{nworkers}} {{if actual_workers > nworkers}} + {{actual_workers-nworkers}} extra {{endif}} ({{nworkers_used}} used including current request)
idle: {{len(track_threads["idle"])}}, busy: {{len(track_threads["busy"])}}, hung: {{len(track_threads["hung"])}}, dying: {{len(track_threads["dying"])}}, zombie: {{len(track_threads["zombie"])}}
{{for thread in threads}}
Thread {{if thread.thread_id == this_thread_id}} (this request) {{endif}} {{thread.thread_id}} {{if allow_kill}}
{{endif}}
Time processing request {{thread.time_html|html}}
URI {{if thread.uri == 'unknown'}} unknown {{else}}{{thread.uri_short}} {{endif}}
▸ Show environ {{if thread.traceback}} ▸ Show traceback {{endif}}
{{endfor}} tnameswatchthreads.page_templatet WatchThreadscBs5eZdZed„Zd„Zd„Zd„ZRS(si Application that watches the threads in ``paste.httpserver``, showing the length each thread has been working on a request. If allow_kill is true, then you can kill errant threads through this application. This application can expose private information (specifically in the environment, like cookies), so it should be protected. cCs ||_dS(N(t allow_kill(tselfR ((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyt__init__¹scCs`d|jo|ddgƒdgS|idƒdjo|i||ƒS|i||ƒSdS( Nspaste.httpserver.thread_pools 403 Forbiddens Content-types text/plainsCYou must use the threaded Paste HTTP server to use this applicationt PATH_INFOs/kill(s Content-types text/plain(tgettkilltshow(R tenvirontstart_response((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyt__call__¼s  cCs‘|ddgƒt|ƒ}|idƒo|d}nd}|d}|i}tiƒ}|iiƒ}|idd„ƒg} x™|D]‘\} \} } tƒ} | i | ƒ| ot | ƒ| _ n d| _ | | _ t || ƒ| _t| i ƒ| _| | _t| ƒ| _qŽWtid d d |d t|iƒd t|ƒd|dd|d|id| dtƒd|iƒƒ }|gS(Ns200 OKs Content-types text/htmlRspaste.httpserver.thread_pooltkeycSs |ddS(ii((tv((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pytÒstunknownttitlesThread Pool Worker Trackertnworkerstactual_workerst nworkers_usedt script_namet SCRIPT_NAMEtkill_thread_idR tthreadstthis_thread_idt track_threads(s Content-types text/html(RR tNoneRttimetworker_trackertitemstsortRtappendRturit thread_idt format_timet time_htmltshortent uri_shortRttraceback_threadt tracebackt page_templatet substitutetlentworkersR RR (R RRtformRt thread_poolRtnowR2RR(t time_startedtworker_environtthreadtpage((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyRÅsF              cCsÌ|iptidƒ}|||ƒSt|ƒ}t|dƒ}|d}||ijo!tid|ƒ}|||ƒS|i|ƒ|dpd}tidd|d |fgƒ}|||ƒS( Ns?Killing threads has not been enabled. Shame on you for trying!R(spaste.httpserver.thread_poolsBYou tried to kill thread %s, but it is not working on any requestsRt/theaderstLocations?kill=%s( R Rt HTTPForbiddenRtintR#tPreconditionFailedt kill_workert HTTPFound(R RRtexctvarsR(R4R((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyRïs"       (t__name__t __module__t__doc__tFalseR RRR(((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyR¬s    *cCscttdƒpdStiƒ}||jodS||}tƒ}ti|d|ƒ|iƒS(sf Returns a plain-text traceback of the given thread, or None if it can't get a traceback. t_current_framestfileN(thasattrtsysR!RHRR.t print_stacktgetvalue(R(tframestframetout((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyR-s    spaste.httpserver.thread_poolc Cs|djotiddddƒSg}xât|iƒƒD]Î\}}|tjoq=nyd|iƒ|jot|ƒ}n|itidt i t |ƒƒdt i t |ƒƒƒƒWq=t j o;}|itidt i t |ƒƒdd|ƒƒq=Xq=Wdi |ƒS(NRs---tvalues-No environment registered for this thread yets Error in repr(): %st(R!tenviron_templateR0tsortedR$t hide_keystuppertreprR&tcgitescapetstrt Exceptiontjoin(Rt environ_rowsRRQte((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pytformat_environs,      cCsç|d jo7dt|ddƒt|dƒd|df}np|djo"dt|dƒ|df}nA|djod|}n&|djod|}n d|}|d jo|S|djo d |Sd |SdS( Ni<s %i:%02i:%02iixs%i:%02is%i secis %0.1f secs %0.2f secis#%ss;%si(R>(t time_lengtht time_string((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyR),s"        cCs0t|ƒdjo|d d|dS|SdS(Ni<i(s...iöÿÿÿ(R1(ts((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyR+BscCs#ddkl}td||ƒƒS(Niÿÿÿÿ(tasboolR (tpaste.deploy.convertersRcR(t global_confR Rc((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pytmake_watch_threadsHsicstˆƒ‰‡fd†}|S(Ncswddk}ˆotiˆƒn9d}x/d||iƒfGHtidƒ|d7}q-|dd gƒd ˆgS( NiÿÿÿÿisI'm alive %s (%s)i is200 OKs content-types text/plainsOK, paused %s seconds(s content-types text/plain(R8R"tsleepR(RRR8tcount(tpause(s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pytbad_appOs   (R>(ReRiRj((Ris</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyt make_bad_appMs  (RFRKRXR"R.t cStringIORR8RtpasteRt paste.requestRRtpaste.util.templateRRR/tobjectRR-RUR_R)R+RGRfRk(((s</usr/lib/python2.6/site-packages/paste/debug/watchthreads.pyts(    ›W