ó
ÐH/\c           @` sp  d  Z  d d l m Z d d l m Z d d l m Z d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d g Z y$ d d l m Z d d  l m Z Wn  e	 k
 rÐ g  Z d! „  Z n Xe Z y e
 d" ƒ Wn e	 k
 rþ e Z nI Xd d# l m Z d d$ l Z z y e j ƒ  Wn n XWd$ [ Xd% „  Z d d& l m Z d d' l m Z d d( l m Z d e f d) „  ƒ  YZ d e f d* „  ƒ  YZ d e f d+ „  ƒ  YZ d e f d, „  ƒ  YZ e e ƒ d e f d- „  ƒ  Yƒ Z d e f d. „  ƒ  YZ d/ e f d0 „  ƒ  YZ e e ƒ d	 e f d1 „  ƒ  Yƒ Z d
 e f d2 „  ƒ  YZ e e ƒ d e f d3 „  ƒ  Yƒ Z d e f d4 „  ƒ  YZ e e ƒ d e f d5 „  ƒ  Yƒ Z  d e f d6 „  ƒ  YZ! d e" f d7 „  ƒ  YZ# e e! ƒ d e  f d8 „  ƒ  Yƒ Z$ d e f d9 „  ƒ  YZ% e e% ƒ d: e  f d; „  ƒ  Yƒ Z& d e! f d< „  ƒ  YZ' e e' ƒ d e$ f d= „  ƒ  Yƒ Z( d e% f d> „  ƒ  YZ) e e) ƒ d e& f d? „  ƒ  Yƒ Z* d e! f d@ „  ƒ  YZ+ dA e f dB „  ƒ  YZ, e e+ ƒ d e, e$ f dC „  ƒ  Yƒ Z- d e% f dD „  ƒ  YZ. e e. ƒ d e, e& f dE „  ƒ  Yƒ Z/ d e% f dF „  ƒ  YZ0 e e0 ƒ d e, e& f dG „  ƒ  Yƒ Z1 d$ S(H   sD  
Publish/subscribe event infrastructure.

When certain "interesting" things happen during the lifetime of the
process, gevent will "publish" an event (an object). That event is
delivered to interested "subscribers" (functions that take one
parameter, the event object).

Higher level frameworks may take this foundation and build richer
models on it.

If :mod:`zope.event` is installed, then it will be used to provide the
functionality of `notify` and `subscribers`. See
:mod:`zope.event.classhandler` for a simple class-based approach to
subscribing to a filtered list of events, and see `zope.component
<https://zopecomponent.readthedocs.io/en/latest/event.html>`_ for a
much higher-level, flexible system. If you are using one of these systems,
you generally will not want to directly modify `subscribers`.

.. versionadded:: 1.3b1
i    (   t   absolute_import(   t   division(   t   print_functiont   subscriberst   IEventLoopBlockedt   EventLoopBlockedt   IMemoryUsageThresholdExceededt   MemoryUsageThresholdExceededt   IMemoryUsageUnderThresholdt   MemoryUsageUnderThresholdt   IPeriodicMonitorThreadt"   IPeriodicMonitorThreadStartedEventt!   PeriodicMonitorThreadStartedEventt   IGeventPatchEventt   GeventPatchEventt   IGeventWillPatchEventt
   DoNotPatcht   GeventWillPatchEventt   IGeventDidPatchEventt   IGeventWillPatchModuleEventt   GeventWillPatchModuleEventt   IGeventDidPatchModuleEventt   GeventDidPatchModuleEventt   IGeventWillPatchAllEventt   GeventWillPatchAllEventt"   IGeventDidPatchBuiltinModulesEventt!   GeventDidPatchBuiltinModulesEventt   IGeventDidPatchAllEventt   GeventDidPatchAllEvent(   R   (   t   notifyc         C` s   x t  D] } | |  ƒ q Wd S(   s6   
        Notify all subscribers of ``event``.
        N(   R   (   t   eventt
   subscriber(    (    s,   lib/python2.7/site-packages/gevent/events.pyR   P   s    t   pkg_resources(   t   iter_entry_pointsNc         C` s>   t  |  ƒ x- t |  j ƒ D] } | j ƒ  } | |  ƒ q Wd  S(   N(   R   R!   t   ENTRY_POINT_NAMEt   load(   R   t   pluginR   (    (    s,   lib/python2.7/site-packages/gevent/events.pyt   notify_and_call_entry_pointsm   s    
(   t	   Interface(   t   implementer(   t	   Attributec           B` s   e  Z d  Z d „  Z RS(   sY   
    The contract for the periodic monitoring thread that is started
    by the hub.
    c         C` s   d S(   s8  
        Schedule the *function* to be called approximately every *period* fractional seconds.

        The *function* receives one argument, the hub being monitored. It is called
        in the monitoring thread, *not* the hub thread. It **must not** attempt to
        use the gevent asynchronous API.

        If the *function* is already a monitoring function, then its *period*
        will be updated for future runs.

        If the *period* is ``None``, then the function will be removed.

        A *period* less than or equal to zero is not allowed.
        N(    (   t   functiont   period(    (    s,   lib/python2.7/site-packages/gevent/events.pyt   add_monitoring_function~   s    (   t   __name__t
   __module__t   __doc__R+   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR
   x   s   c           B` s   e  Z d  Z e d ƒ Z RS(   s   
    The event emitted when a hub starts a periodic monitoring thread.

    You can use this event to add additional monitoring functions.
    s:   The instance of `IPeriodicMonitorThread` that was started.(   R,   R-   R.   R(   t   monitor(    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   Ž   s   c           B` s   e  Z d  Z d Z d „  Z RS(   sL   
    The implementation of :class:`IPeriodicMonitorThreadStartedEvent`.
    s2   gevent.plugins.hub.periodic_monitor_thread_startedc         C` s   | |  _  d  S(   N(   R/   (   t   selfR/   (    (    s,   lib/python2.7/site-packages/gevent/events.pyt   __init__    s    (   R,   R-   R.   R"   R1   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   —   s   c           B` s2   e  Z d  Z e d ƒ Z e d ƒ Z e d ƒ Z RS(   sm   
    The event emitted when the event loop is blocked.

    This event is emitted in the monitor thread.
    s3   The greenlet that appeared to be blocking the loop.s:   The approximate time in seconds the loop has been blocked.s0   A sequence of string lines providing extra info.(   R,   R-   R.   R(   t   greenlett   blocking_timet   info(    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   £   s   c           B` s   e  Z d  Z d „  Z RS(   s`   
    The event emitted when the event loop is blocked.

    Implements `IEventLoopBlocked`.
    c         C` s   | |  _  | |  _ | |  _ d  S(   N(   R2   R3   R4   (   R0   R2   R3   R4   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR1   ¶   s    		(   R,   R-   R.   R1   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   ®   s   c           B` s2   e  Z d  Z e d ƒ Z e d ƒ Z e d ƒ Z RS(   sE  
    The event emitted when the memory usage threshold is exceeded.

    This event is emitted only while memory continues to grow
    above the threshold. Only if the condition or stabilized is corrected (memory
    usage drops) will the event be emitted in the future.

    This event is emitted in the monitor thread.
    s+   The current process memory usage, in bytes.s+   The maximum allowed memory usage, in bytes.s1   The tuple of memory usage stats return by psutil.(   R,   R-   R.   R(   t	   mem_usaget   max_allowedt   memory_info(    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   »   s   	t   _AbstractMemoryEventc           B` s   e  Z d  „  Z d „  Z RS(   c         C` s   | |  _  | |  _ | |  _ d  S(   N(   R5   R6   R7   (   R0   R5   R6   R7   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR1   Ì   s    		c         C` s#   d |  j  j |  j |  j |  j f S(   Ns   <%s used=%d max=%d details=%r>(   t	   __class__R,   R5   R6   R7   (   R0   (    (    s,   lib/python2.7/site-packages/gevent/events.pyt   __repr__Ñ   s
    	(   R,   R-   R1   R:   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR8   Ê   s   	c           B` s   e  Z d  Z RS(   s<   
    Implementation of `IMemoryUsageThresholdExceeded`.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   Ù   s   c           B` s>   e  Z d  Z e d ƒ Z e d ƒ Z e d ƒ Z e d ƒ Z RS(   sÄ  
    The event emitted when the memory usage drops below the
    threshold after having previously been above it.

    This event is emitted only the first time memory usage is detected
    to be below the threshold after having previously been above it.
    If memory usage climbs again, a `IMemoryUsageThresholdExceeded`
    event will be broadcast, and then this event could be broadcast again.

    This event is emitted in the monitor thread.
    s+   The current process memory usage, in bytes.s+   The maximum allowed memory usage, in bytes.sN   The memory usage that caused the previous IMemoryUsageThresholdExceeded event.s1   The tuple of memory usage stats return by psutil.(   R,   R-   R.   R(   R5   R6   t   max_memory_usageR7   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   à   s
   c           B` s   e  Z d  Z d „  Z RS(   s9   
    Implementation of `IMemoryUsageUnderThreshold`.
    c         C` s)   t  t |  ƒ j | | | ƒ | |  _ d  S(   N(   t   superR	   R1   R;   (   R0   R5   R6   R7   t	   max_usage(    (    s,   lib/python2.7/site-packages/gevent/events.pyR1   ú   s    (   R,   R-   R.   R1   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR	   ô   s   c           B` s&   e  Z d  Z e d ƒ Z e d ƒ Z RS(   s<   
    The root for all monkey-patch events gevent emits.
    s)   The source object containing the patches.s%   The destination object to be patched.(   R,   R-   R.   R(   t   sourcet   target(    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   ÿ   s   c           B` s    e  Z d  Z d „  Z d „  Z RS(   s0   
    Implementation of `IGeventPatchEvent`.
    c         C` s   | |  _  | |  _ d  S(   N(   R>   R?   (   R0   R>   R?   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR1     s    	c         C` s&   d |  j  j |  j |  j t |  ƒ f S(   Ns   <%s source=%r target=%r at %x>(   R9   R,   R>   R?   t   id(   R0   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR:     s    (   R,   R-   R.   R1   R:   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR     s   	c           B` s   e  Z d  Z RS(   sª   
    An event emitted *before* gevent monkey-patches something.

    If a subscriber raises `DoNotPatch`, then patching this particular
    item will not take place.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR     s   c           B` s   e  Z d  Z RS(   s‚   
    Subscribers to will-patch events can raise instances
    of this class to tell gevent not to patch that particular item.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR      s   c           B` s   e  Z d  Z RS(   s4   
    Implementation of `IGeventWillPatchEvent`.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   '  s   c           B` s   e  Z d  Z RS(   s@   
    An event emitted *after* gevent has patched something.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   -  s   t   GeventDidPatchEventc           B` s   e  Z d  Z RS(   s3   
    Implementation of `IGeventDidPatchEvent`.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyRA   2  s   c           B` s&   e  Z d  Z e d ƒ Z e d ƒ Z RS(   sŒ   
    An event emitted *before* gevent begins patching a specific module.

    Both *source* and *target* attributes are module objects.
    sN   The name of the module being patched. This is the same as ``target.__name__``.sL   The list of item names to patch. This can be modified in place with caution.(   R,   R-   R.   R(   t   module_namet   target_item_names(    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   8  s   c           B` s   e  Z d  Z d Z d „  Z RS(   s:   
    Implementation of `IGeventWillPatchModuleEvent`.
    s'   gevent.plugins.monkey.will_patch_modulec         C` s/   t  t |  ƒ j | | ƒ | |  _ | |  _ d  S(   N(   R<   R   R1   RB   RC   (   R0   RB   R>   R?   t   items(    (    s,   lib/python2.7/site-packages/gevent/events.pyR1   O  s    	(   R,   R-   R.   R"   R1   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   E  s   c           B` s   e  Z d  Z e d ƒ Z RS(   sW   
    An event emitted *after* gevent has completed patching a specific
    module.
    sN   The name of the module being patched. This is the same as ``target.__name__``.(   R,   R-   R.   R(   RB   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   U  s   c           B` s   e  Z d  Z d Z d „  Z RS(   s9   
    Implementation of `IGeventDidPatchModuleEvent`.
    s&   gevent.plugins.monkey.did_patch_modulec         C` s&   t  t |  ƒ j | | ƒ | |  _ d  S(   N(   R<   R   R1   RB   (   R0   RB   R>   R?   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR1   i  s    (   R,   R-   R.   R"   R1   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   _  s   c           B` s/   e  Z d  Z e d ƒ Z e d ƒ Z d „  Z RS(   s·  
    An event emitted *before* gevent begins patching the system.

    Following this event will be a series of
    `IGeventWillPatchModuleEvent` and `IGeventDidPatchModuleEvent` for
    each patched module.

    Once the gevent builtin modules have been processed,
    `IGeventDidPatchBuiltinModulesEvent` will be emitted. Processing
    this event is an ideal time for third-party modules to be imported
    and patched (which may trigger its own will/did patch module
    events).

    Finally, a `IGeventDidPatchAllEvent` will be sent.

    If a subscriber to this event raises `DoNotPatch`, no patching
    will be done.

    The *source* and *target* attributes have undefined values.
    sh   A dictionary of all the arguments to `gevent.monkey.patch_all`. This dictionary should not be modified. sj   A dictionary of the extra arguments to `gevent.monkey.patch_all`. This dictionary should not be modified. c         C` s   d S(   sP   
        Return whether the module named *module_name* will be patched.
        N(    (   RB   (    (    s,   lib/python2.7/site-packages/gevent/events.pyt   will_patch_module  s    (   R,   R-   R.   R(   t   patch_all_argumentst   patch_all_kwargsRE   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   p  s   		t   _PatchAllMixinc           B` s8   e  Z d  „  Z e d „  ƒ Z e d „  ƒ Z d „  Z RS(   c         C` s/   t  t |  ƒ j d  d  ƒ | |  _ | |  _ d  S(   N(   R<   RH   R1   t   Nonet   _patch_all_argumentst   _patch_all_kwargs(   R0   RF   RG   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR1   –  s    	c         C` s   |  j  j ƒ  S(   N(   RJ   t   copy(   R0   (    (    s,   lib/python2.7/site-packages/gevent/events.pyRF   ›  s    c         C` s   |  j  j ƒ  S(   N(   RK   RL   (   R0   (    (    s,   lib/python2.7/site-packages/gevent/events.pyRG   Ÿ  s    c         C` s    d |  j  j |  j t |  ƒ f S(   Ns   <%s %r at %x>(   R9   R,   RJ   R@   (   R0   (    (    s,   lib/python2.7/site-packages/gevent/events.pyR:   £  s    (   R,   R-   R1   t   propertyRF   RG   R:   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyRH   •  s   	c           B` s   e  Z d  Z d Z d „  Z RS(   s7   
    Implementation of `IGeventWillPatchAllEvent`.
    s$   gevent.plugins.monkey.will_patch_allc         C` s   |  j  j | ƒ S(   N(   RF   t   get(   R0   RB   (    (    s,   lib/python2.7/site-packages/gevent/events.pyRE   ²  s    (   R,   R-   R.   R"   RE   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   ¨  s   c           B` s&   e  Z d  Z e d ƒ Z e d ƒ Z RS(   s   
    Event emitted *after* the builtin modules have been patched.

    The values of the *source* and *target* attributes are undefined.
    sh   A dictionary of all the arguments to `gevent.monkey.patch_all`. This dictionary should not be modified. sj   A dictionary of the extra arguments to `gevent.monkey.patch_all`. This dictionary should not be modified. (   R,   R-   R.   R(   RF   RG   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   µ  s
   	c           B` s   e  Z d  Z d Z RS(   sA   
    Implementation of `IGeventDidPatchBuiltinModulesEvent`.
    s(   gevent.plugins.monkey.did_patch_builtins(   R,   R-   R.   R"   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   Æ  s   c           B` s   e  Z d  Z RS(   sÀ   
    Event emitted after gevent has patched all modules, both builtin
    and those provided by plugins/subscribers.

    The values of the *source* and *target* attributes are undefined.
    (   R,   R-   R.   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   Ð  s   c           B` s   e  Z d  Z d Z RS(   s6   
    Implementation of `IGeventDidPatchAllEvent`.
    s#   gevent.plugins.monkey.did_patch_all(   R,   R-   R.   R"   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyR   Ø  s   (2   R.   t
   __future__R    R   R   t   __all__t
   zope.eventR   R   t   ImportErrort
   __import__R%   R    R!   t   platformt   unamet   gevent._utilR&   R'   R(   R
   R   t   objectR   R   R   R   R8   R   R   R	   R   R   R   t   BaseExceptionR   R   R   RA   R   R   R   R   R   RH   R   R   R   R   R   (    (    (    s,   lib/python2.7/site-packages/gevent/events.pyt   <module>   s¶   		
 		
	
%	