%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/debug/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyo

�
a�Nc@sdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZedd	d
�Zdefd��YZd
�ZdgZd�Zd�Zd�Zed�Zeje_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
<html>
 <head>
  <style type="text/css">
   body {
     font-family: sans-serif;
   }
   table.environ tr td {
     border-bottom: #bbb 1px solid;
   }
   table.environ tr td.bottom {
     border-bottom: none;
   }
   table.thread {
     border: 1px solid #000;
     margin-bottom: 1em;
   }
   table.thread tr td {
     border-bottom: #999 1px solid;
     padding-right: 1em;
   }
   table.thread tr td.bottom {
     border-bottom: none;
   }
   table.thread tr.this_thread td {
     background-color: #006;
     color: #fff;
   }
   a.button {
     background-color: #ddd;
     border: #aaa outset 2px;
     text-decoration: none;
     margin-top: 10px;
     font-size: 80%;
     color: #000;
   }
   a.button:hover {
     background-color: #eee;
     border: #bbb outset 2px;
   }
   a.button:active {
     border: #bbb inset 2px;
   }
  </style>
  <title>{{title}}</title>
 </head>
 <body>
  <h1>{{title}}</h1>
  {{if kill_thread_id}}
  <div style="background-color: #060; color: #fff;
              border: 2px solid #000;">
  Thread {{kill_thread_id}} killed
  </div>
  {{endif}}
  <div>Pool size: {{nworkers}}
       {{if actual_workers > nworkers}}
         + {{actual_workers-nworkers}} extra
       {{endif}}
       ({{nworkers_used}} used including current request)<br>
       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"])}}</div>

{{for thread in threads}}

<table class="thread">
 <tr {{if thread.thread_id == this_thread_id}}class="this_thread"{{endif}}>
  <td>
   <b>Thread</b>
   {{if thread.thread_id == this_thread_id}}
   (<i>this</i> request)
   {{endif}}</td>
  <td>
   <b>{{thread.thread_id}}
    {{if allow_kill}}
    <form action="{{script_name}}/kill" method="POST"
          style="display: inline">
      <input type="hidden" name="thread_id" value="{{thread.thread_id}}">
      <input type="submit" value="kill">
    </form>
    {{endif}}
   </b>
  </td>
 </tr>
 <tr>
  <td>Time processing request</td>
  <td>{{thread.time_html|html}}</td>
 </tr>
 <tr>
  <td>URI</td>
  <td>{{if thread.uri == 'unknown'}}
      unknown
      {{else}}<a href="{{thread.uri}}">{{thread.uri_short}}</a>
      {{endif}}
  </td>
 <tr>
  <td colspan="2" class="bottom">
   <a href="#" class="button" style="width: 9em; display: block"
      onclick="
        var el = document.getElementById('environ-{{thread.thread_id}}');
        if (el.style.display) {
            el.style.display = '';
            this.innerHTML = '&#9662; Hide environ';
        } else {
            el.style.display = 'none';
            this.innerHTML = '&#9656; Show environ';
        }
        return false
      ">&#9656; Show environ</a>
   
   <div id="environ-{{thread.thread_id}}" style="display: none">
    {{if thread.environ:}}
    <table class="environ">
     {{for loop, item in looper(sorted(thread.environ.items()))}}
     {{py:key, value=item}}
     <tr>
      <td {{if loop.last}}class="bottom"{{endif}}>{{key}}</td>
      <td {{if loop.last}}class="bottom"{{endif}}>{{value}}</td>
     </tr>
     {{endfor}}
    </table>
    {{else}}
    Thread is in process of starting
    {{endif}}
   </div>

   {{if thread.traceback}}
   <a href="#" class="button" style="width: 9em; display: block"
      onclick="
        var el = document.getElementById('traceback-{{thread.thread_id}}');
        if (el.style.display) {
            el.style.display = '';
            this.innerHTML = '&#9662; Hide traceback';
        } else {
            el.style.display = 'none';
            this.innerHTML = '&#9656; Show traceback';
        }
        return false
      ">&#9656; Show traceback</a>

    <div id="traceback-{{thread.thread_id}}" style="display: none">
      <pre class="traceback">{{thread.traceback}}</pre>
    </div>
    {{endif}}

  </td>
 </tr>
</table>

{{endfor}}

 </body>
</html>
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	((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyt__init__�scCs\d|kr#|ddg�dgS|jd�dkrH|j||�S|j||�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((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyt__call__�scCs�|ddg�t|�}|jd�r8|d}nd}|d}|j}tj�}|jj�}|jdd��g}	x�|D]�\}
\}}t�}
|	j	|
�|r�t
|�|
_n	d|
_|
|
_t
||�|
_t|
j�|
_||
_t|
�|
_q�Wtjd	d
d|dt|j�d
t|�d|dd|d|jd|	dt�d|j��
}|gS(Ns200 OKsContent-types	text/htmlRspaste.httpserver.thread_pooltkeycSs|ddS(Nii((tv((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyt<lambda>�stunknownttitlesThread Pool Worker Trackertnworkerstactual_workerst
nworkers_usedtscript_nametSCRIPT_NAMEtkill_thread_idR	tthreadstthis_thread_idt
track_threads(sContent-types	text/html(RR
tNoneRttimetworker_trackertitemstsortRtappendRturit	thread_idtformat_timet	time_htmltshortent	uri_shortRttraceback_threadt	tracebackt
page_templatet
substitutetlentworkersR	RR (R
RRtformRtthread_poolRtnowR2RR(ttime_startedtworker_environtthreadtpage((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyR�sD

		
				
		cCs�|js%tjd�}|||�St|�}t|d�}|d}||jkrztjd|�}|||�S|j|�|dp�d}tjdd|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#tPreconditionFailedtkill_workert	HTTPFound(R
RRtexctvarsR(R4R((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyR�s"		




	(t__name__t
__module__t__doc__tFalseRRRR(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyR�s
			*cCs_ttd�sdStj�}||kr/dS||}t�}tj|d|�|j�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.tprint_stacktgetvalue(R(tframestframetout((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyR-s
	spaste.httpserver.thread_poolc	Cs|dkr"tjdddd�Sg}x�t|j��D]�\}}|tkrYq;nyb|j�|kr}t|�}n|jtjdt	j
t|��dt	j
t|����Wq;tk
r}|jtjdt	j
t|��dd|��q;Xq;Wdj
|�S(NRs---tvalues-No environment registered for this thread yets Error in <code>repr()</code>: %st(R!tenviron_templateR0tsortedR$t	hide_keystuppertreprR&tcgitescapetstrt	Exceptiontjoin(Rtenviron_rowsRRQte((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pytformat_environs*			cCs�|dkrBdt|dd�t|d�d|df}ni|dkrodt|d�|df}n<|dkr�d|}n#|dkr�d|}n
d|}|d	kr�|S|dkr�d
|Sd|SdS(
Ni<s%i:%02i:%02iixs%i:%02is%i secis	%0.1f secs	%0.2f secis#<span style="color: #900">%s</span>s;<span style="background-color: #600; color: #fff">%s</span>i(R>(ttime_lengthttime_string((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyR),s"


cCs.t|�dkr&|d d|dS|SdS(Ni<i(s...i����(R1(ts((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyR+BscCs#ddlm}td||��S(Ni����(tasboolR	(tpaste.deploy.convertersRcR(tglobal_confR	Rc((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pytmake_watch_threadsHsicst����fd�}|S(Ncsuddl}�r"tj��n8d}x/d||j�fGHtjd�|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(sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pytbad_appOs

(R>(ReRiRj((RisI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pytmake_bad_appMs(RFRKRXR"R.t	cStringIORR8RtpasteRt
paste.requestRRtpaste.util.templateRRR/tobjectRR-RUR_R)R+RGRfRk(((sI/opt/alt/python27/lib/python2.7/site-packages/paste/debug/watchthreads.pyt<module>s(�W					

Zerion Mini Shell 1.0