Your IP : 216.73.216.196
B
0-�^� � @ s` d dl mZ d dlZd dlmZ ddlmZmZ G dd� de�Z ej
fdd �Zd
d� Ze� Z
dS )� )�unicode_literalsN)�Lock� )�mmap_key�
MmapedDictc @ s4 e Zd ZdZdZdd� Zdd� Zdd� Zd d
� ZdS )�
MutexValuezA float protected by a mutex.Fc K s d| _ t� | _d S )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__ s zMutexValue.__init__c C s$ | j � | j|7 _W d Q R X d S )N)r r )r
�amountr r r �inc s zMutexValue.incc C s | j � || _W d Q R X d S )N)r r )r
�valuer r r �set s zMutexValue.setc C s | j � | jS Q R X d S )N)r r )r
r r r �get s zMutexValue.getN) �__name__�
__module__�__qualname__�__doc__�
_multiprocessr r r r r r r r r s r c s8 i � g �d�� i�t � �G � ����fdd�dt�}|S )a8 Returns 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.
r c sh e Zd ZdZdZd��fdd� Z� �fdd�Z� ���fdd �Z�fd
d�Z�fdd
�Z �fdd�Z
dS )z&MultiProcessValue.<locals>.MmapedValuezAA float protected by a mutex backed by a per-process mmaped file.T� c s@ ||||||f| _ � � | �� | �� ��| � W d Q R X d S )N)�_params�"_MmapedValue__check_for_pid_change�_MmapedValue__reset�append)r
r r r
r r �multiprocess_moder )�lock�valuesr r r 4 s
z/MultiProcessValue.<locals>.MmapedValue.__init__c s� | j \}}}}}}|dkr(|d | }n|}|� kr`tj�tjd d�|�d ��}t|�� |<