HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/gunicorn/__pycache__/systemd.cpython-310.pyc
o

%we�	�@s,ddlZddlZdZd	dd�Zd
dd�ZdS)�N�TcCsXttj�dd��}ttj�dd��}|t��krdS|r*tj�dd�tj�dd�|S)a`
    Get the number of sockets inherited from systemd socket activation.

    :param unset_environment: clear systemd environment variables unless False
    :type unset_environment: bool
    :return: the number of sockets to inherit from systemd socket activation
    :rtype: int

    Returns zero immediately if $LISTEN_PID is not set to the current pid.
    Otherwise, returns the number of systemd activation sockets specified by
    $LISTEN_FDS.

    When $LISTEN_PID matches the current pid, unsets the environment variables
    unless the ``unset_environment`` flag is ``False``.

    .. note::
        Unlike the sd_listen_fds C function, this implementation does not set
        the FD_CLOEXEC flag because the gunicorn arbiter never needs to do this.

    .. seealso::
        `<https://www.freedesktop.org/software/systemd/man/sd_listen_fds.html>`_

    �
LISTEN_FDSr�
LISTEN_PIDN)�int�os�environ�get�getpid�pop)�unset_environment�fds�
listen_pid�r�I/home/arjun/projects/env/lib/python3.10/site-packages/gunicorn/systemd.py�
listen_fdssrFc	Cs�tj�d�}|durdSzHz(t�tjtjtjB�}|ddkr'd|dd�}|�|�|�|�	d��Wnt
yE|jdd	d
�YnwW|rOtj�d�|�
�dS|r]tj�d�|�
�w)aSend a notification to systemd. state is a string; see
    the man page of sd_notify (http://www.freedesktop.org/software/systemd/man/sd_notify.html)
    for a description of the allowable values.

    If the unset_environment parameter is True, sd_notify() will unset
    the $NOTIFY_SOCKET environment variable before returning (regardless of
    whether the function call itself succeeded or not). Further calls to
    sd_notify() will then fail, but the variable is no longer inherited by
    child processes.
    �
NOTIFY_SOCKETNr�@��zutf-8z$Exception while invoking sd_notify()T)�exc_info)rrr�socket�AF_UNIX�
SOCK_DGRAM�SOCK_CLOEXEC�connect�sendall�encode�	Exception�debugr
�close)�state�loggerr�addr�sockrrr�	sd_notify1s&
���
r$)T)F)rr�SD_LISTEN_FDS_STARTrr$rrrr�<module>s

%