AlkantarClanX12
Current Path : /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/ |
Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/semaphore_tracker.cpython-35.pyc |
��Yf� � @ s� d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d d g Z Gd d � d e � Z e � Z e j Z e j Z e j Z e j Z d d � Z d S)� N� )�spawn)�util�ensure_running�register� unregisterc @ sX e Z d Z d d � Z d d � Z d d � Z d d � Z d d � Z d d � Z d S)�SemaphoreTrackerc C s t j � | _ d | _ d S)N)� threadingZLock�_lock�_fd)�self� r �F/opt/alt/python35/lib64/python3.5/multiprocessing/semaphore_tracker.py�__init__ s zSemaphoreTracker.__init__c C s | j � | j S)N)r r )r r r r �getfd! s zSemaphoreTracker.getfdc C s | j �� | j d k r d Sg } y | j t j j � � Wn t k rQ Yn Xd } t j � \ } } z yW | j | � t j � } | g t j � } | d | | g 7} t j | | | � Wn t j | � � Yn X| | _ Wd t j | � XWd QRXd S)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�piper Zget_executabler Z_args_from_interpreter_flagsZspawnv_passfds�close)r Zfds_to_pass�cmd�r�wZexe�argsr r r r % s* zSemaphoreTracker.ensure_runningc C s | j d | � d S)z2Register name of semaphore with semaphore tracker.ZREGISTERN)�_send)r �namer r r r C s zSemaphoreTracker.registerc C s | j d | � d S)z4Unregister name of semaphore with semaphore tracker.Z UNREGISTERN)r )r r r r r r G s zSemaphoreTracker.unregisterc C st | j � d j | | � j d � } t | � d k rC t d � � t j | j | � } | t | � k sp t � d S)Nz{0}:{1} �asciii z name too long) r �format�encode�len� ValueErrorr �writer �AssertionError)r r r �msg�nbytesr r r r K s zSemaphoreTracker._sendN) �__name__� __module__�__qualname__r r r r r r r r r r r s r c - C s� t j t j t j � t j t j t j � x= t j t j f D]) } y | j � Wq? t k rg Yq? Xq? Wt � } z� t | d � �� } x� | D]� } yg | j � j d � \ } } | d k r� | j | � n, | d k r� | j | � n t d | � � Wq� t k r4y t j t j � � Wn Yn XYq� Xq� WWd QRXWd | rzy t j d t | � � Wn t k ryYn Xxu | D]m } zc | j d � } y t j | � Wn<