%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/zmq/devices/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyo

�
+�{Wc@s�dZddlZddlmZddlmZddlmZmZm	Z	m
Z
mZddd��YZdefd	��YZ
d
e
fd��YZde
fd
��YZdd
dgZdS(s2Classes for running 0MQ Devices in the background.i����N(tThread(tProcess(tdevicetQUEUEtContexttETERMtZMQErrortDevicecBs�eZdZejZed
d
d�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd	�Zd
�Zd�Zd
d�ZRS(scA 0MQ Device to be run in the background.
    
    You do not pass Socket instances to this, but rather Socket types::

        Device(device_type, in_socket_type, out_socket_type)

    For instance::

        dev = Device(zmq.QUEUE, zmq.DEALER, zmq.ROUTER)

    Similar to zmq.device, but socket types instead of sockets themselves are
    passed, and the sockets are created in the work thread, to avoid issues
    with thread safety. As a result, additional bind_{in|out} and
    connect_{in|out} methods and setsockopt_{in|out} allow users to specify
    connections for the sockets.
    
    Parameters
    ----------
    device_type : int
        The 0MQ Device type
    {in|out}_type : int
        zmq socket types, to be passed later to context.socket(). e.g.
        zmq.PUB, zmq.SUB, zmq.REQ. If out_type is < 0, then in_socket is used
        for both in_socket and out_socket.
        
    Methods
    -------
    bind_{in_out}(iface)
        passthrough for ``{in|out}_socket.bind(iface)``, to be called in the thread
    connect_{in_out}(iface)
        passthrough for ``{in|out}_socket.connect(iface)``, to be called in the
        thread
    setsockopt_{in_out}(opt,value)
        passthrough for ``{in|out}_socket.setsockopt(opt, value)``, to be called in
        the thread
    
    Attributes
    ----------
    daemon : int
        sets whether the thread should be run as a daemon
        Default is true, because if it is false, the thread will not
        exit unless it is killed
    context_factory : callable (class attribute)
        Function for creating the Context. This will be Context.instance
        in ThreadDevices, and Context in ProcessDevices.  The only reason
        it is not instance() in ProcessDevices is that there may be a stale
        Context instance already initialized, and the forked environment
        should *never* try to use it.
    cCs�||_|dkr$td��n|dkr?td��n||_||_g|_g|_g|_g|_g|_	g|_
t|_t
|_dS(Nsin_type must be specifiedsout_type must be specified(tdevice_typetNonet	TypeErrortin_typetout_typet	_in_bindst_in_connectst_in_sockoptst
_out_bindst
_out_connectst
_out_sockoptstTruetdaemontFalsetdone(tselfRRR((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyt__init__Fs										cCs|jj|�dS(s`Enqueue ZMQ address for binding on in_socket.

        See zmq.Socket.bind for details.
        N(R
tappend(Rtaddr((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytbind_inWscCs|jj|�dS(sfEnqueue ZMQ address for connecting on in_socket.

        See zmq.Socket.connect for details.
        N(RR(RR((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyt
connect_in^scCs|jj||f�dS(seEnqueue setsockopt(opt, value) for in_socket

        See zmq.Socket.setsockopt for details.
        N(RR(Rtopttvalue((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyt
setsockopt_inescCs|jj|�dS(saEnqueue ZMQ address for binding on out_socket.

        See zmq.Socket.bind for details.
        N(RR(RR((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytbind_outlscCs|jj|�dS(sgEnqueue ZMQ address for connecting on out_socket.

        See zmq.Socket.connect for details.
        N(RR(RR((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytconnect_outsscCs|jj||f�dS(sfEnqueue setsockopt(opt, value) for out_socket

        See zmq.Socket.setsockopt for details.
        N(RR(RRR((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytsetsockopt_outzscCs3|j�}||_|j|j�}|jdkr?|}n|j|j�}x'|jD]\}}|j||�q[Wx'|jD]\}}|j||�q�Wx|jD]}|j	|�q�Wx|j
D]}|j	|�q�Wx|jD]}|j|�q�Wx|j
D]}|j|�qW||fS(Ni(tcontext_factoryt_contexttsocketRRRt
setsockoptRR
tbindRRtconnectR(RtctxtinstoutsRRtiface((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyt_setup_sockets�s&		cCs)|j�\}}t|j||�dS(spThe runner method.

        Do not call me directly, instead call ``self.start()``, just like a Thread.
        N(R-RR(RR*R+((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyt
run_device�scCsNz=y|j�Wn(tk
r;}|jtkr5q<�nXWdt|_XdS(s"wrap run_device in try/catch ETERMN(R.RterrnoRRR(Rte((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytrun�scCs
|j�S(s>Start the device. Override me in subclass for other launchers.(R1(R((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytstart�scCs]tj�}|}xD|jrX|dk	o8|||krXtjd�tj�}qWdS(sdwait for me to finish, like Thread.join.
        
        Reimplemented appropriately by subclasses.g����MbP?N(ttimeRR	tsleep(Rttimeouttticttoc((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pytjoin�s
*
N(t__name__t
__module__t__doc__RtinstanceR#RR	RRRRR R!R"R-R.R1R2R8(((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyRs1										
	tBackgroundDevicecBs/eZdZdZdZd�Zdd�ZRS(sEBase class for launching Devices in background processes and threads.cCs4|jd|j�|_|j|j_|jj�S(Nttarget(t
_launch_classR1tlauncherRR2(R((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyR2�scCs|jjd|�S(NR5(R@R8(RR5((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyR8�sN(R9R:R;R	R@R?R2R8(((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyR=�s
	tThreadDevicecBseZdZeZRS(sSA Device that will be run in a background Thread.

    See Device for details.
    (R9R:R;RR?(((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyRA�st
ProcessDevicecBseZdZeZeZRS(sTA Device that will be run in a background Process.

    See Device for details.
    (R9R:R;RR?RR#(((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyRB�s((R;R3t	threadingRtmultiprocessingRtzmqRRRRRRR=RARBt__all__(((s</usr/lib64/python2.7/site-packages/zmq/devices/basedevice.pyt<module>s(�

Zerion Mini Shell 1.0