
X?_c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 m
 Z
 m Z d d l m Z m Z m Z e j   Z d e f d     YZ d e f d     YZ y d d l Z d d l Z Wn e k
 r d \ Z Z n Xd	 e f d
     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e e j f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d S(   s2   Site services for use with a Web Site Process Bus.iN(   t
   basestringt
   get_daemont   get_thread_ident(   t   ntobt   Timert   SetDaemonPropertyt   SimplePluginc           B   s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   sC   Plugin base class which auto-subscribes methods for known channels.c         C   s   | |  _  d  S(   N(   t   bus(   t   selfR   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   __init__(   s    c         C   sO   xH |  j  j D]: } t |  | d  } | d k	 r |  j  j | |  q q Wd S(   s>   Register this object as a (multi-channel) listener on the bus.N(   R   t	   listenerst   getattrt   Nonet	   subscribe(   R   t   channelt   method(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   +   s    c         C   sO   xH |  j  j D]: } t |  | d  } | d k	 r |  j  j | |  q q Wd S(   s0   Unregister this object as a listener on the bus.N(   R   R
   R   R   t   unsubscribe(   R   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   3   s    N(   t   __name__t
   __module__t   __doc__R   R   R	   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR       s
   		t   SignalHandlerc           B   s   e  Z d  Z i  Z i  Z xL e e  j   D]8 \ Z Z	 e j
 d  r+ e j
 d  r+ e e e	 <q+ q+ W[ [	 d   Z d
 d
 d  Z d   Z d   Z d
 d  Z d
 d
 d  Z d	   Z RS(   s  Register bus channels (and listeners) for system signals.

    You can modify what signals your application listens for, and what it does
    when it receives signals, by modifying :attr:`SignalHandler.handlers`,
    a dict of {signal name: callback} pairs. The default set is::

        handlers = {'SIGTERM': self.bus.exit,
                    'SIGHUP': self.handle_SIGHUP,
                    'SIGUSR1': self.bus.graceful,
                   }

    The :func:`SignalHandler.handle_SIGHUP`` method calls
    :func:`bus.restart()<cherrypy.process.wspbus.Bus.restart>`
    if the process is daemonized, but
    :func:`bus.exit()<cherrypy.process.wspbus.Bus.exit>`
    if the process is attached to a TTY. This is because Unix window
    managers tend to send SIGHUP to terminal windows when the user closes them.

    Feel free to add signals which are not available on every platform.
    The :class:`SignalHandler` will ignore errors raised from attempting
    to register handlers for unknown signals.
    t   SIGt   SIG_c         C   s   | |  _  i |  j  j d 6|  j d 6|  j  j d 6|  _ t j d  d k r |  j d =|  j  j |  j d <|  j  j d  |  j |  j d <n  i  |  _	 d  S(	   Nt   SIGTERMt   SIGHUPt   SIGUSR1i   t   javat   SIGUSR2sA   SIGUSR1 cannot be set on the JVM platform. Using SIGUSR2 instead.t   SIGINT(
   R   t   exitt   handle_SIGHUPt   gracefult   handlerst   syst   platformt   logt   _jython_SIGINT_handlert   _previous_handlers(   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	   `   s    	

c         C   s!   |  j  j d  |  j  j   d  S(   Ns%   Keyboard Interrupt: shutting down bus(   R   R#   R   (   R   t   signumt   frame(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR$   q   s    c         C   sL   xE |  j  j   D]4 \ } } y |  j | |  Wq t k
 rC q Xq Wd S(   s#   Subscribe self.handlers to signals.N(   R    t   itemst   set_handlert
   ValueError(   R   t   sigt   func(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   v   s
    c         C   s   x |  j  j   D] \ } } |  j | } | d	 k rU |  j j d |  t j } n |  j j d | | f  yE t j | |  } | d	 k r |  j j d | | f d d n  Wq t	 k
 r |  j j d | | f d d d t
 q Xq Wd	 S(
   s'   Unsubscribe self.handlers from signals.s    Restoring %s handler to SIG_DFL.s   Restoring %s handler %r.s?   Restored old %s handler %r, but our handler was not registered.t   leveli   s    Unable to restore %s handler %r.i(   t	   tracebackN(   R%   R(   t   signalsR   R   R#   t   _signalt   SIG_DFLt   signalR*   t   True(   R   R&   t   handlert   signamet   our_handler(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   ~   s    c         C   s   t  | t  rI t t | d  } | d k r@ t d |   n  | } n; y |  j | } Wn! t k
 r} t d |   n X| } t j | |  j	  } | |  j
 | <| d k	 r |  j j d |  |  j j | |  n  d S(   s=  Subscribe a handler for the given signal (number or name).

        If the optional 'listener' argument is provided, it will be
        subscribed as a listener for the given signal's channel.

        If the given signal name or number is not available on the current
        platform, ValueError is raised.
        s   No such signal: %rs   Listening for %s.N(   t
   isinstanceR    R   R0   R   R*   R/   t   KeyErrorR2   t   _handle_signalR%   R   R#   R   (   R   R2   t   listenerR&   R5   t   prev(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR)      s    		c         C   s5   |  j  | } |  j j d |  |  j j |  d S(   s?   Python signal handler (self.set_handler subscribes it for you).s   Caught signal %s.N(   R/   R   R#   t   publish(   R   R&   R'   R5   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR9      s    c         C   sY   t  j t j j    r8 |  j j d  |  j j   n |  j j d  |  j j   d S(   s!   Restart if daemonized, else exit.s*   SIGHUP caught but not daemonized. Exiting.s+   SIGHUP caught while daemonized. Restarting.N(	   t   ost   isattyR!   t   stdint   filenoR   R#   R   t   restart(   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR      s
    N(   R   R   R   R    R/   t   varsR0   R(   t   kt   vt
   startswithR	   R   R$   R   R   R)   R9   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   <   s   			t   DropPrivilegesc           B   s   e  Z d  Z d d d d  Z d   Z d   Z e e e d d Z d   Z	 d   Z
 e e	 e
 d d Z d	   Z d
   Z e e e d d Z d   Z d e _ RS(   s   Drop privileges. uid/gid arguments not available on Windows.

    Special thanks to `Gavin Baker <http://antonym.org/2005/12/dropping-privileges-in-python.html>`_
    c         C   s8   t  j |  |  t |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R	   t   Falset	   finalizedt   uidt   gidt   umask(   R   R   RK   RI   RJ   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	      s
    			c         C   s   |  j  S(   N(   t   _uid(   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   _get_uid   s    c         C   sl   | d  k	 r_ t d  k r7 |  j j d d d d  } q_ t | t  r_ t j |  d } q_ n  | |  _ d  S(   Ns'   pwd module not available; ignoring uid.R-   i   i   (   R   t   pwdR   R#   R7   R    t   getpwnamRL   (   R   t   val(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   _set_uid   s    	t   docs/   The uid under which to run. Availability: Unix.c         C   s   |  j  S(   N(   t   _gid(   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   _get_gid   s    c         C   sl   | d  k	 r_ t d  k r7 |  j j d d d d  } q_ t | t  r_ t j |  d } q_ n  | |  _ d  S(   Ns'   grp module not available; ignoring gid.R-   i   i   (   R   t   grpR   R#   R7   R    t   getgrnamRS   (   R   RP   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   _set_gid   s    	s/   The gid under which to run. Availability: Unix.c         C   s   |  j  S(   N(   t   _umask(   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt
   _get_umask   s    c         C   sW   | d  k	 rJ y t j WqJ t k
 rF |  j j d d d d  } qJ Xn  | |  _ d  S(   Ns-   umask function not available; ignoring umask.R-   i   (   R   R=   RK   t   AttributeErrorR   R#   RX   (   R   RP   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt
   _set_umask   s    s   The default permission mode for newly created files and
        directories.

        Usually expressed in octal format, for example, ``0644``.
        Availability: Unix, Windows.
        c         C   s  d   } |  j  rM |  j d  k o- |  j d  k s|  j j d |    qn |  j d  k r |  j d  k r t sw t r|  j j d d d qn |  j j d |    |  j d  k	 r t j	 |  j  t j
 g   n  |  j d  k	 r t j |  j  n  |  j j d |    |  j  rG|  j d  k	 r|  j j d |  j  qnW |  j d  k ro|  j j d	 d d n/ t j |  j  } |  j j d
 | |  j f  t |  _  d  S(   Nc          S   sZ   d \ }  } t r. t j t j    d }  n  t rP t j t j    d } n  |  | f S(   s+   Return the current (uid, gid) if available.i    N(   NN(   R   RN   t   getpwuidR=   t   getuidRU   t   getgrgidt   getgid(   t   namet   group(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   current_ids  s    s"   Already running as uid: %r gid: %rs   uid/gid not setR-   i   s   Started as uid: %r gid: %rs   Running as uid: %r gid: %rs   umask already set to: %03os   umask not sets   umask old: %03o, new: %03o(   RH   RI   R   RJ   R   R#   RN   RU   R=   t   setgidt	   setgroupst   setuidRK   R3   (   R   Rb   t	   old_umask(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   start	  s0    				iM   N(   R   R   R   R   R	   RM   RQ   t   propertyRI   RT   RW   RJ   RY   R[   RK   Rg   t   priority(    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyRF      s$   													,t
   Daemonizerc           B   s2   e  Z d  Z d d d d  Z d   Z d e _ RS(   s  Daemonize the running script.

    Use this with a Web Site Process Bus via::

        Daemonizer(bus).subscribe()

    When this component finishes, the process is completely decoupled from
    the parent environment. Please note that when this component is used,
    the return code from the parent process will still be 0 if a startup
    error occurs in the forked children. Errors in the initial daemonizing
    process still return proper exit codes. Therefore, if you use this
    plugin to daemonize, don't use the return code as an accurate indicator
    of whether the process fully started. In fact, that return code only
    indicates if the process succesfully finished the first fork.
    s	   /dev/nullc         C   s8   t  j |  |  | |  _ | |  _ | |  _ t |  _ d  S(   N(   R   R	   R?   t   stdoutt   stderrRG   RH   (   R   R   R?   Rk   Rl   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	   J  s
    			c         C   sW  |  j  r |  j j d  n  t j   d k rQ |  j j d t j   d d n  t j j   t j	 j   y< t
 j   } | d k r n |  j j d  t
 j d  WnH t k
 r t j   d } t j d t j d | j | j f  n Xt
 j   y< t
 j   } | d k r7|  j j d	  t
 j d  n  WnH t k
 rt j   d } t j d
 t j d | j | j f  n Xt
 j d  t
 j d  t |  j d  } t |  j d  } t |  j	 d  } t
 j | j   t j j    t
 j | j   t j j    t
 j | j   t j	 j    |  j j d t
 j    t |  _  d  S(   Ns   Already deamonized.i   sH   There are %r active threads. Daemonizing now may cause strange failures.R-   i   i    s   Forking once.s   %s: fork #1 failed: (%d) %s
s   Forking twice.s   %s: fork #2 failed: (%d) %s
t   /t   rs   a+s   Daemonized to PID: %s(   RH   R   R#   t	   threadingt   activeCountt	   enumerateR!   Rk   t   flushRl   R=   t   forkt   _exitt   OSErrort   exc_infoR   t   argvt   errnot   strerrort   setsidt   chdirRK   t   openR?   t   dup2R@   t   getpidR3   (   R   t   pidt   exct   sit   sot   se(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyRg   R  sJ    		"
	"iA   (   R   R   R   R	   Rg   Ri   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyRj   8  s
   	Ct   PIDFilec           B   s2   e  Z d  Z d   Z d   Z d e _ d   Z RS(   s!   Maintain a PID file via a WSPBus.c         C   s&   t  j |  |  | |  _ t |  _ d  S(   N(   R   R	   t   pidfileRG   RH   (   R   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	     s    	c         C   s   t  j   } |  j r5 |  j j d | |  j f  nL t |  j d  j t d | d   |  j j d | |  j f  t	 |  _ d  S(   Ns   PID %r already written to %r.t   wbs   %s
t   utf8s   PID %r written to %r.(
   R=   R~   RH   R   R#   R   R|   t   writeR   R3   (   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyRg     s    	 &iF   c         C   sR   y+ t  j |  j  |  j j d |  j  Wn  t t f k
 rG   n n Xd  S(   Ns   PID file removed: %r.(   R=   t   removeR   R   R#   t   KeyboardInterruptt
   SystemExit(   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s    (   R   R   R   R	   Rg   Ri   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s
   			t   PerpetualTimerc           B   s    e  Z d  Z d   Z d   Z RS(   s  A responsive subclass of threading.Timer whose run() method repeats.

    Use this timer only when you really need a very interruptible timer;
    this checks its 'finished' condition up to 20 times a second, which can
    results in pretty high CPU usage
    c         O   s2   | j  d d  |  _ t t |   j | |   d S(   s:   Override parent constructor to allow 'bus' to be provided.R   N(   t   popR   R   t   superR   R	   (   R   t   argst   kwargs(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	     s    c         C   s   x t  r |  j j |  j  |  j j   r/ d  Sy |  j |  j |  j   Wq t k
 r |  j	 r |  j	 j
 d |  j d d d t  n    q Xq Wd  S(   Ns,   Error in perpetual timer thread function %r.R-   i(   R.   (   R3   t   finishedt   waitt   intervalt   isSett   functionR   R   t	   ExceptionR   R#   (   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   run  s    			(   R   R   R   R	   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s   	t   BackgroundTaskc           B   s2   e  Z d  Z g  i  d d  Z d   Z d   Z RS(   s  A subclass of threading.Thread whose run() method repeats.

    Use this class for most repeating tasks. It uses time.sleep() to wait
    for each interval, which isn't very responsive; that is, even if you call
    self.cancel(), you'll have to wait until the sleep() call finishes before
    the thread stops. To compensate, it defaults to being daemonic, which means
    it won't delay stopping the whole process.
    c         C   sS   t  j j |   | |  _ | |  _ | |  _ | |  _ t |  _ | |  _	 t
 |  _ d  S(   N(   Ro   t   ThreadR	   R   R   R   R   RG   t   runningR   R3   t   daemon(   R   R   R   R   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	     s    						c         C   s   t  |  _ d  S(   N(   RG   R   (   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   cancel  s    c         C   s   t  |  _ x |  j r t j |  j  |  j s2 d  Sy |  j |  j |  j   Wq t k
 r |  j	 r |  j	 j
 d |  j d d d t  n    q Xq Wd  S(   Ns,   Error in background task thread function %r.R-   i(   R.   (   R3   R   t   timet   sleepR   R   R   R   R   R   R#   (   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s    			N(   R   R   R   R   R	   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s   		t   Monitorc           B   sS   e  Z d  Z d Z d Z d Z d d d  Z d   Z d e _	 d   Z
 d   Z RS(   sA   WSPBus listener to periodically run a callback in its own thread.i<   c         C   s8   t  j |  |  | |  _ | |  _ d  |  _ | |  _ d  S(   N(   R   R	   t   callbackt	   frequencyR   t   threadR`   (   R   R   R   R   R`   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	     s
    			c         C   s   |  j  d k r |  j p! |  j j } |  j d k r t |  j  |  j d |  j |  _ |  j j	 |  |  j j
   |  j j d |  q |  j j d |  n  d S(   s0   Start our callback in its own background thread.i    R   s   Started monitor thread %r.s"   Monitor thread %r already started.N(   R   R`   t	   __class__R   R   R   R   R   R   t   setNameRg   R#   (   R   t
   threadname(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyRg     s    iF   c         C   s   |  j  d k r5 |  j j d |  j p. |  j j  n |  j  t j   k	 r |  j  j	   } |  j  j
   t |  j   s |  j j d |  |  j  j   n  |  j j d |  n  d |  _  d S(   s+   Stop our callback's background task thread.s   No thread running for %s.s
   Joining %rs   Stopped thread %r.N(   R   R   R   R#   R`   R   R   Ro   t   currentThreadt   getNameR   R   t   join(   R   R`   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   stop!  s    c         C   s   |  j    |  j   d S(   s:   Stop the callback's background task thread and restart it.N(   R   Rg   (   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   0  s    
N(   R   R   R   R   R   R   R   R	   Rg   Ri   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s   			t   Autoreloaderc           B   sS   e  Z d  Z d Z d Z d Z d d d  Z d   Z d e _	 d   Z
 d   Z RS(	   sQ  Monitor which re-executes the process when files change.

    This :ref:`plugin<plugins>` restarts the process (via :func:`os.execv`)
    if any of the files it monitors change (or is deleted). By default, the
    autoreloader monitors all imported modules; you can add to the
    set by adding to ``autoreload.files``::

        cherrypy.engine.autoreload.files.add(myFile)

    If there are imported files you do *not* wish to monitor, you can
    adjust the ``match`` attribute, a regular expression. For example,
    to stop monitoring cherrypy itself::

        cherrypy.engine.autoreload.match = r'^(?!cherrypy).+'

    Like all :class:`Monitor<cherrypy.process.plugins.Monitor>` plugins,
    the autoreload plugin takes a ``frequency`` argument. The default is
    1 second; that is, the autoreloader will examine files once each second.
    i   s   .*c         C   s;   i  |  _  t   |  _ | |  _ t j |  | |  j |  d  S(   N(   t   mtimest   sett   filest   matchR   R	   R   (   R   R   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	   U  s    		c         C   s,   |  j  d k r i  |  _ n  t j |   d S(   s2   Start our own background task thread for self.run.N(   R   R   R   R   Rg   (   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyRg   [  s    iF   c         C   s   t    } x t t j j    D] \ } } t j |  j |  r t | d  rp t | j d  rp | j j	 } nU t
 | d d  } | d k	 r t j j |  r t j j t j j t |   } n  | j |  q q W| S(   s1   Return a Set of sys.modules filenames to monitor.t
   __loader__t   archivet   __file__N(   R   t   listR!   t   modulesR(   t   reR   t   hasattrR   R   R   R   R=   t   patht   isabst   normpathR   t   _module__file__baset   add(   R   R   RC   t   mt   f(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   sysfilesb  s    	"	c         C   s$  x|  j    |  j BD]} | r | j d  r< | d  } n  |  j j | d  } | d k rc q n  y t j |  j } Wn t	 k
 r d } n X| |  j k r | |  j | <q| d k s | | k r|  j
 j d |  |  j j   |  j
 j d |  j j    |  j
 j   d Sq q Wd S(   s:   Reload the process if registered files have been modified.s   .pycii    s   Restarting because %s changed.s   Stopped thread %r.N(   R   R   t   endswithR   t   getR   R=   t   statt   st_mtimeRu   R   R#   R   R   R   RA   (   R   t   filenamet   oldtimet   mtime(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   v  s*    
N(   R   R   R   R   R   R   R   R	   Rg   Ri   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR   6  s   			t   ThreadManagerc           B   s>   e  Z d  Z d Z d   Z d   Z d   Z d   Z e Z	 RS(   s  Manager for HTTP request threads.

    If you have control over thread creation and destruction, publish to
    the 'acquire_thread' and 'release_thread' channels (for each thread).
    This will register/unregister the current thread and publish to
    'start_thread' and 'stop_thread' listeners in the bus as needed.

    If threads are created and destroyed by code you do not control
    (e.g., Apache), then, at the beginning of every HTTP request,
    publish to 'acquire_thread' only. You should not publish to
    'release_thread' in this case, since you do not know whether
    the thread will be re-used or not. The bus will call
    'stop_thread' listeners for you when it stops.
    c         C   s   i  |  _  t j |  |  |  j j j d t    |  j j j d t    |  j j j d t    |  j j j d t    d  S(   Nt   acquire_threadt   start_threadt   release_threadt   stop_thread(   t   threadsR   R	   R   R
   t
   setdefaultR   (   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR	     s    	c         C   sR   t    } | |  j k rN t |  j  d } | |  j | <|  j j d |  n  d S(   s   Run 'start_thread' listeners for the current thread.

        If the current thread has already been seen, any 'start_thread'
        listeners will not be run again.
        i   R   N(   R   R   t   lenR   R<   (   R   t   thread_identt   i(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s
    	c         C   sD   t    } |  j j | d  } | d k	 r@ |  j j d |  n  d S(   s;   Release the current thread and run 'stop_thread' listeners.R   N(   R   R   R   R   R   R<   (   R   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s    	c         C   sD   x0 |  j  j   D] \ } } |  j j d |  q W|  j  j   d S(   s8   Release all threads and run all 'stop_thread' listeners.R   N(   R   R(   R   R<   t   clear(   R   R   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s    N(
   R   R   R   R   R   R	   R   R   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyR     s   				(   NN(!   R   R=   R   R2   R0   R!   R   Ro   t   cherrypy._cpcompatR    R   R   R   R   R   t   getcwdR   t   objectR   R   RN   RU   t   ImportErrorR   RF   Rj   R   R   R   R   R   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/process/plugins.pyt   <module>   s0   q`*9a