
L]c           @  s  d  Z  d d l m Z m Z m Z d d l Z d d l Z ya d d l Z d d l m	 Z	 d d l m
 Z
 e e
 j d  s e d e e d d	    n  Wn1 e k
 r d
 d l m
 Z
 d
 d l m	 Z	 n Xe
 j Z d e f d     YZ d   Z e e _ d e
 j k r"d
 d l m Z n. e
 j Z x" e j   e k	 rOe j   Z q.Wd e f d     YZ e Z d   Z d e
 j k rd
 d l m Z m Z m Z n  d S(   s   tornado IOLoop API with zmq compatibility

This module is deprecated in pyzmq 17.
To use zmq with tornado,
eventloop integration is no longer required
and tornado itself should be used.
i    (   t   absolute_importt   divisiont   with_statementN(   t   gen_log(   t   ioloopt   configurable_defaults   Tornado too old: %st   versiont   unknowni   t   DelayedCallbackc           B  s,   e  Z d  Z d d  Z d   Z d   Z RS(   s   Schedules the given callback to be called once.

    The callback is called once, after callback_time milliseconds.

    `start` must be called after the DelayedCallback is created.
    
    The timeout is calculated from when `start` is called.
    c         C  s?   t  j d t  t | d  } t t |   j | | |  d  S(   NsD   DelayedCallback is deprecated.
        Use loop.add_timeout instead.gMbP?(   t   warningst   warnt   DeprecationWarningt   maxt   superR   t   __init__(   t   selft   callbackt   callback_timet   io_loop(    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR   (   s    
c         C  sI   t  |  _ t  |  _ t j   |  j d |  _ |  j j |  j |  j  d S(   s   Starts the timer.g     @@N(	   t   Truet   _runningt	   _firstrunt   timeR   t   _next_timeoutR   t   add_timeoutt   _run(   R   (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyt   start/   s    		c         C  sO   |  j  s d  St |  _  y |  j   Wn$ t k
 rJ t j d d t n Xd  S(   Ns   Error in delayed callbackt   exc_info(   R   t   FalseR   t	   ExceptionR   t   errorR   (   R   (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR   6   s    	 	N(   t   __name__t
   __module__t   __doc__t   NoneR   R   R   (    (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR      s   	c           C  s0   t  j r d  St t  _ t j d t d d d  S(   Nsl   zmq.eventloop.ioloop is deprecated in pyzmq 17. pyzmq now works with default tornado and asyncio eventloops.t
   stackleveli   (   t   _deprecatedt   calledR   R	   R
   R   (    (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR$   ?   s
    			s   .minitornado.(   t	   ZMQIOLoopR&   c           B  s5   e  Z d  Z d   Z e d    Z e d    Z RS(   s   DEPRECATED: No longer needed as of pyzmq-17

    PyZMQ tornado integration now works with the default :mod:`tornado.ioloop.IOLoop`.
    c         O  s   t    t t |   j   S(   N(   R$   R   R&   R   (   R   t   argst   kwargs(    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR   X   s    c         O  s0   t  j j |   t   t  j j | |   } | S(   s  Returns a global `IOLoop` instance.

        Most applications have a single, global `IOLoop` running on the
        main thread.  Use this method to get this instance from
        another thread.  To get the current thread's `IOLoop`, use `current()`.
        (   R   t   IOLoopt	   configureR$   t   instance(   t   clsR'   R(   t   loop(    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR+   ]   s    
c         O  s0   t  j j |   t   t  j j | |   } | S(   s/   Returns the current thread’s IOLoop.
        (   R   R)   R*   R$   t   current(   R,   R'   R(   R-   (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR.   l   s    (   R   R    R!   R   t   classmethodR+   R.   (    (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyR&   R   s   	c           C  s   t    t j j t  d S(   sR   DEPRECATED

    pyzmq 17 no longer needs any special integration for tornado.
    N(   R$   R   R)   R*   R&   (    (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyt   install|   s    (   R&   R0   R)   (   R!   t
   __future__R    R   R   R   R	   t   tornadot   tornado.logR   R   t   hasattrR)   t   ImportErrort   getattrt   minitornadot   minitornado.logt   PeriodicCallbackR   R$   R   R%   R   R&   t   _IOLoopR   R0   (    (    (    s3   lib/python2.7/site-packages/zmq/eventloop/ioloop.pyt   <module>   s4   #	 			'	
