관리-도구
편집 파일: semaphore_tracker.cpython-35.opt-2.pyc
���]� � @ 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)� threading�Lock�_lock�_fd)�self� r �6/opt/alt/python35/lib64/python3.5/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)Nz;from multiprocessing.semaphore_tracker import main;main(%d)z-c)r r �append�sys�stderr�fileno� Exception�os�piper Zget_executabler �_args_from_interpreter_flags�spawnv_passfds�close)r Zfds_to_pass�cmd�r�wZexe�argsr r r r % s* zSemaphoreTracker.ensure_runningc C s | j d | � d S)NZREGISTER)�_send)r �namer r r r C s zSemaphoreTracker.registerc C s | j d | � d S)NZ UNREGISTER)r )r r! r r r r G s zSemaphoreTracker.unregisterc C s\ | j � d j | | � j d � } t | � d k rC t d � � t j | j | � } d S)Nz{0}:{1} �asciii z name too long)r �format�encode�len� ValueErrorr �writer )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<