HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/zmq/utils/__pycache__/win32.cpython-310.pyc
o

�N�gB�@s�UdZddlZddlmZGdd�d�Zeeed<ejdkrPddlmZm	Z	dd	l
mZmZe	�
d
�Zeee�ZejZeefe_ee_Gdd�de�ZeZdSeZdS)
zWin32 compatibility utilities.�N)�Typec@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)�_allow_interruptaDUtility 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.
    NcCs|�|�dS)aTranslate ``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)�_init_action��self�action�r�C/opt/saltstack/salt/lib/python3.10/site-packages/zmq/utils/win32.py�__init__@s	z_allow_interrupt.__init__cC�dS�Nrrrrr	rK�z_allow_interrupt._init_actioncCs|Srr)rrrr	�	__enter__Nr
z_allow_interrupt.__enter__cGrrr)r�argsrrr	�__exit__Qr
z_allow_interrupt.__exit__r)�__name__�
__module__�__qualname__�__doc__r
rrrrrrr	r
s
2r�allow_interrupt�nt)�WINFUNCTYPE�windll)�BOOL�DWORD�kernel32c@s*eZdZejZdd�Zdd�Zdd�ZdS)�_real_allow_interruptcs0�durdd���|_t�fdd��}||_dS)NcSrrrrrrr	�<lambda>hsz4_real_allow_interrupt._init_action.<locals>.<lambda>cs|dkr��dS)Nrr)�event�rrr	�handleksz2_real_allow_interrupt._init_action.<locals>.handle)r�PHANDLER_ROUTINEr )rrr rrr	rfs
z"_real_allow_interrupt._init_actioncCst|jd�}|dkr
t��dS)z"Install the custom CTRL-C handler.�rN��SetConsoleCtrlHandlerr �OSError)r�resultrrr	ry��z_real_allow_interrupt.__enter__cGst|jd�}|dkr
t��dS)z!Remove the custom CTRL-C handler.rNr#)rrr&rrr	r�r'z_real_allow_interrupt.__exit__N)rrrrrrrrrrrr	rcs
r)r�os�typingrr�__annotations__�name�ctypesrrZctypes.wintypesrr�LoadLibraryrr!r$�argtypes�restyperrrrrr	�<module>s H



&