Your IP : 3.23.101.75


Current Path : /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/semaphore_tracker.cpython-35.pyc



��Yf��@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZdddgZ	Gdd	�d	e
�Ze�Zej
Z
ejZejZejZd
d�ZdS)�N�)�spawn)�util�ensure_running�register�
unregisterc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�SemaphoreTrackercCstj�|_d|_dS)N)�	threadingZLock�_lock�_fd)�self�r
�F/opt/alt/python35/lib64/python3.5/multiprocessing/semaphore_tracker.py�__init__szSemaphoreTracker.__init__cCs|j�|jS)N)rr)rr
r
r�getfd!s
zSemaphoreTracker.getfdcCs|j��|jdk	rdSg}y|jtjj��Wntk
rQYnXd}tj�\}}zyW|j|�t	j
�}|gtj�}|d||g7}tj
|||�Wntj|��Yn
X||_Wdtj|�XWdQRXdS)z�Make sure that semaphore tracker process is running.

        This can be run from any process.  Usually a child process will use
        the semaphore created by its parent.Nz;from multiprocessing.semaphore_tracker import main;main(%d)z-c)r
r�append�sys�stderr�fileno�	Exception�os�piperZget_executablerZ_args_from_interpreter_flagsZspawnv_passfds�close)rZfds_to_pass�cmd�r�wZexe�argsr
r
rr%s*




zSemaphoreTracker.ensure_runningcCs|jd|�dS)z2Register name of semaphore with semaphore tracker.ZREGISTERN)�_send)r�namer
r
rrCszSemaphoreTracker.registercCs|jd|�dS)z4Unregister name of semaphore with semaphore tracker.Z
UNREGISTERN)r)rrr
r
rrGszSemaphoreTracker.unregistercCst|j�dj||�jd�}t|�dkrCtd��tj|j|�}|t|�kspt�dS)Nz{0}:{1}
�asciiiz
name too long)	r�format�encode�len�
ValueErrorr�writer�AssertionError)rrr�msg�nbytesr
r
rrKs
zSemaphoreTracker._sendN)	�__name__�
__module__�__qualname__rrrrrrr
r
r
rrsrc-Cs�tjtjtj�tjtjtj�x=tjtjfD])}y|j�Wq?tk
rgYq?Xq?Wt	�}z�t
|d���}x�|D]�}yg|j�jd�\}}|dkr�|j
|�n,|dkr�|j|�ntd|��Wq�tk
r4ytjtj��WnYnXYq�Xq�WWdQRXWd|rzytjdt|��Wntk
ryYnXxu|D]m}zc|jd�}ytj|�Wn<tk
r�}ztjd	||f�WYdd}~XnXWdXq�WXdS)
zRun semaphore tracker.�rb�:sREGISTERs
UNREGISTERzunrecognized command %rNzRsemaphore_tracker: There appear to be %d leaked semaphores to clean up at shutdownrzsemaphore_tracker: %r: %s)�signal�SIGINT�SIG_IGN�SIGTERMr�stdin�stdoutrr�set�open�strip�split�add�remove�RuntimeError�
excepthook�exc_info�warnings�warnr"�decode�_multiprocessingZ
sem_unlink)�fd�f�cache�linerr�er
r
r�main]sJ
		

	

.rE)rr-rr	r<r?�rr�__all__�objectrZ_semaphore_trackerrrrrrEr
r
r
r�<module>s;					

?>