%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python2.7/site-packages/zmq/utils/
Upload File :
Create Path :
Current File : //lib64/python2.7/site-packages/zmq/utils/win32.pyo

�
+�{Wc@s�dZddlZdefd��YZejdkr�ddlmZmZddlm	Z	m
Z
ejd�Zee	e
�Z
ejZe
e	fe_e	e_d	efd
��YZnd	efd��YZdS(sWin32 compatibility utilities.i����Nt_allow_interruptcBs5eZdZdd�Zd�Zd�Zd�ZRS(sDUtility for fixing CTRL-C events on Windows.

    On Windows, the Python interpreter intercepts CTRL-C events in order to
    translate them into ``KeyboardInterrupt`` exceptions.  It (presumably)
    does this by setting a flag in its "console control handler" and
    checking it later at a convenient location in the interpreter.

    However, when the Python interpreter is blocked waiting for the ZMQ
    poll operation to complete, it must wait for ZMQ's ``select()``
    operation to complete before translating the CTRL-C event into the
    ``KeyboardInterrupt`` exception.

    The only way to fix this seems to be to add our own "console control
    handler" and perform some application-defined operation that will
    unblock the ZMQ polling operation in order to force ZMQ to pass control
    back to the Python interpreter.

    This context manager performs all that Windows-y stuff, providing you
    with a hook that is called when a CTRL-C event is intercepted.  This
    hook allows you to unblock your ZMQ poll operation immediately, which
    will then result in the expected ``KeyboardInterrupt`` exception.

    Without this context manager, your ZMQ-based application will not
    respond normally to CTRL-C events on Windows.  If a CTRL-C event occurs
    while blocked on ZMQ socket polling, the translation to a
    ``KeyboardInterrupt`` exception will be delayed until the I/O completes
    and control returns to the Python interpreter (this may never happen if
    you use an infinite timeout).

    A no-op implementation is provided on non-Win32 systems to avoid the
    application from having to conditionally use it.

    Example usage:

    .. sourcecode:: python

       def stop_my_application():
           # ...

       with allow_interrupt(stop_my_application):
           # main polling loop.

    In a typical ZMQ application, you would use the "self pipe trick" to
    send message to a ``PAIR`` socket in order to interrupt your blocking
    socket polling operation.

    In a Tornado event loop, you can use the ``IOLoop.stop`` method to
    unblock your I/O loop.
    cCs|j|�dS(sTranslate ``action`` into a CTRL-C handler.

        ``action`` is a callable that takes no arguments and returns no
        value (returned value is ignored).  It must *NEVER* raise an
        exception.
        
        If unspecified, a no-op will be used.
        N(t_init_action(tselftaction((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyt__init__>s	cCsdS(N((RR((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyRIscCs|S(N((R((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyt	__enter__LscGsdS(N((Rtargs((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyt__exit__OsN(t__name__t
__module__t__doc__tNoneRRRR(((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyRs
1		tnt(tWINFUNCTYPEtwindll(tBOOLtDWORDtkernel32tallow_interruptcBs,eZejZd�Zd�Zd�ZRS(csC�dkrd��n�|_t�fd��}||_dS(NcSsdS(N(R(((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyt<lambda>cscs|dkr��ndS(Ni((tevent(R(s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pythandlees
(RRtPHANDLER_ROUTINER(RRR((Rs5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyRas
	cCs.t|jd�}|dkr*t��ndS(s"Install the custom CTRL-C handler.iiN(tSetConsoleCtrlHandlerRtWindowsError(Rtresult((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyRrscGs.t|jd�}|dkr*t��ndS(s!Remove the custom CTRL-C handler.iN(RRR(RRR((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyRzs(RR	RR
RRR(((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyR^s			cBseZejZRS((RR	RR
(((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyR�s	(R
tostobjectRtnametctypesR
Rtctypes.wintypesRRtLoadLibraryRRRtargtypestrestypeR(((s5/usr/lib64/python2.7/site-packages/zmq/utils/win32.pyt<module>sG		$

Zerion Mini Shell 1.0