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__/pidfile.cpython-310.pyc
o

%we?	�@s,ddlZddlZddlZGdd�de�ZdS)�Nc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Pidfilez�    Manage a PID file. If a specific name is provided
    it and '"%s.oldpid" % name' will be used. Otherwise
    we create a temp file using os.mkstemp.
    cCs||_d|_dS�N)�fname�pid)�selfr�r�I/home/arjun/projects/env/lib/python3.10/site-packages/gunicorn/pidfile.py�__init__s
zPidfile.__init__cCs�|��}|r|t��krdSd}t|||jf��||_tj�|j�}|r1tj�|�s1td|��t	j
|d�\}}t�|d|j�d��|jrPt�
||j�n||_t�|�t�|jd�dS)Nz5Already running on PID %s (or pid file '%s' is stale)z'%s doesn't exist. Can't create pidfile.)�dirz%s
zutf-8i�)�validate�os�getpid�RuntimeErrorrr�path�dirname�isdir�tempfile�mkstemp�write�encode�rename�close�chmod)rr�oldpid�msg�fdir�fdrrrr�creates"
zPidfile.createcCs|��||_|�|j�dSr)�unlinkrrr)rrrrrr/szPidfile.renamecCstz/t|jd��}t|��pd�}Wd�n1swY||jkr-t�|j�WdSWdSty9YdSw)z delete pidfile�rrN)�openr�int�readrrr�	Exception)r�f�pid1rrrr4s�
��zPidfile.unlinkcCs6|jsdSzyt|jd��h}zt|���}Wnty&YWd�WdSwzt�|d�|WWd�WStys}z/|jdt	j
krX|WYd}~Wd�WS|jdt	jkrnWYd}~Wd�WdS�d}~ww1swwYWdSty�}z|jdt	j
kr�WYd}~dS�d}~ww)z- Validate pidfile and make it stale if neededNrr)rr r!r"�
ValueErrorr�kill�OSError�args�errno�EPERM�ESRCH�IOError�ENOENT)rr$�wpid�errrr?s>��	�
������zPidfile.validateN)	�__name__�
__module__�__qualname__�__doc__r	rrrrrrrrrsr)r*rr�objectrrrrr�<module>s