Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/prometheus_client/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/prometheus_client/__pycache__/values.cpython-37.pyc

B

0-�^��@s`ddlmZddlZddlmZddlmZmZGdd�de�Z	ej
fdd	�Zd
d�Ze�Z
dS)�)�unicode_literalsN)�Lock�)�mmap_key�
MmapedDictc@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�
MutexValuezA float protected by a mutex.FcKsd|_t�|_dS)Ng)�_valuer�_lock)�self�typ�metric_name�name�
labelnames�labelvalues�kwargs�r�I/opt/alt/python37/lib/python3.7/site-packages/prometheus_client/values.py�__init__szMutexValue.__init__c	Cs$|j�|j|7_WdQRXdS)N)r	r)r
�amountrrr�incszMutexValue.incc	Cs|j�||_WdQRXdS)N)r	r)r
�valuerrr�setszMutexValue.setc	Cs|j�|jSQRXdS)N)r	r)r
rrr�getszMutexValue.getN)	�__name__�
__module__�__qualname__�__doc__�
_multiprocessrrrrrrrrr	srcs8i�g�d��i�t��G�����fdd�dt�}|S)a8Returns a MmapedValue class based on a process_identifier function.

    The 'process_identifier' function MUST comply with this simple rule:
    when called in simultaneously running processes it MUST return distinct values.

    Using a different function than the default 'os.getpid' is at your own risk.
    rcsheZdZdZdZd��fdd�	Z��fdd�Z����fdd	�Z�fd
d�Z�fdd
�Z	�fdd�Z
dS)z&MultiProcessValue.<locals>.MmapedValuezAA float protected by a mutex backed by a per-process mmaped file.T�c	s@||||||f|_�� |��|����|�WdQRXdS)N)�_params�"_MmapedValue__check_for_pid_change�_MmapedValue__reset�append)r
rrr
rr�multiprocess_moder)�lock�valuesrrr4s
z/MultiProcessValue.<locals>.MmapedValue.__init__c	s�|j\}}}}}}|dkr(|d|}n|}|�kr`tj�tjdd�|�d��}t|��|<�||_t||||�|_	|j�
|j	�|_dS)NZgauge�_�prometheus_multiproc_dirz
{0}_{1}.dbr)r�os�path�join�environ�formatr�_filer�_keyZ
read_valuer)	r
rrr
rrr#Zfile_prefix�filename)�files�pidrrZ__reset;s
z.MultiProcessValue.<locals>.MmapedValue.__resetcsV��}�d|krR|�d<x���D]}|��q$W���x�D]}|��qBWdS)Nr)r%�close�clearr!)r
Z
actual_pid�fr)r0r1�process_identifierr%rrZ__check_for_pid_changeKs
z=MultiProcessValue.<locals>.MmapedValue.__check_for_pid_changec	s<��.|��|j|7_|j�|j|j�WdQRXdS)N)r rr-�write_valuer.)r
r)r$rrrVsz*MultiProcessValue.<locals>.MmapedValue.incc	s4��&|��||_|j�|j|j�WdQRXdS)N)r rr-r6r.)r
r)r$rrr\sz*MultiProcessValue.<locals>.MmapedValue.setc	s��|��|jSQRXdS)N)r r)r
)r$rrrbsz*MultiProcessValue.<locals>.MmapedValue.getN)r)rrrrrrr!r rrrr)r0r$r1r5r%rr�MmapedValue/sr7)r�object)r5r7r)r0r$r1r5r%r�MultiProcessValues
8r9cCsdtjkrt�StSdS)Nr')r(r+r9rrrrr�get_value_classjs
r:)�
__future__rr(�	threadingrZ	mmap_dictrrr8r�getpidr9r:Z
ValueClassrrrr�<module>sK