관리-도구
편집 파일: thread.cpython-39.pyc
a �����DOgC"����������������������@���s����d�Z�dZddlmZ�ddlZddlZddlZddlZddlZddl Z e� ��Zdae� ��Zdd��Ze�e��ee d�r�e jejejejd ��G�d d��de�Zdd ��ZG�dd��dej�ZG�dd��dej�ZdS�)zImplements ThreadPoolExecutor.z"Brian Quinlan (brian@sweetapp.com)�����)�_baseNFc������������������C���sf���t���daW�d�����n1�s0����Y��tt����}�|�D�]\}}|�d���q8|�D�]\}}|����qPd�S��NT)�_global_shutdown_lock� _shutdown�list�_threads_queues�items�put�join)r����t�q��r ����1/usr/lib64/python3.9/concurrent/futures/thread.py�_python_exit���s����"r����register_at_fork)�before�after_in_child�after_in_parentc�������������������@���s&���e�Zd�Zdd��Zdd��Zeej�ZdS�)� _WorkItemc�����������������C���s���||�_�||�_||�_||�_d�S��N)�future�fn�args�kwargs)�selfr���r���r���r���r ���r ���r����__init__/���s����z_WorkItem.__init__c�������������� ���C���sl���|�j����sd�S�z|�j|�ji�|�j��}W�n4�tyZ�}�z|�j��|��d�}�W�Y�d�}~nd�}~0�0�|�j��|��d�S�r���)r����set_running_or_notify_cancelr���r���r���� BaseException� set_exception� set_result)r����result�excr ���r ���r����run5���s���� z _WorkItem.runN) �__name__� __module__�__qualname__r���r"����classmethod�types�GenericAlias�__class_getitem__r ���r ���r ���r���r���.���s��� r���c�����������������C���s����|d�urPz||���W�n:�t�yN���tjjddd��|���}|d�urH|����Y�d�S�0�zx|jdd�}|d�ur�|����~|���}|d�ur�|j����~qR|���}t s�|d�u�s�|j r�|d�ur�d|_ |� d���W�d�S�~qRW�n"�t�y����tjjddd��Y�n0�d�S�)NzException in initializer:T)�exc_info)�blockzException in worker)r���r����LOGGER�critical�_initializer_failed�getr"����_idle_semaphore�releaser���r ���)�executor_referenceZ work_queue�initializer�initargs�executor� work_itemr ���r ���r����_workerE���s8���� r7���c�������������������@���s���e�Zd�ZdZdS�)�BrokenThreadPoolzR Raised when a worker thread in a ThreadPoolExecutor failed initializing. N)r#���r$���r%����__doc__r ���r ���r ���r���r8���p���s���r8���c�������������������@���s`���e�Zd�Ze���jZddd�Zdd��Ze j jje_dd ��Zd d��Z dd d�dd�Ze j jje_dS�)�ThreadPoolExecutorN��r ���c�����������������C���s����|du�rt�dt���pdd��}|dkr.td��|durFt|�sFtd��||�_t���|�_ t �d�|�_t ��|�_d|�_d|�_t ���|�_|p�d |�����|�_||�_||�_dS�) a���Initializes a new ThreadPoolExecutor instance. Args: max_workers: The maximum number of threads that can be used to execute the given calls. thread_name_prefix: An optional name prefix to give our threads. initializer: A callable used to initialize worker threads. initargs: A tuple of arguments to pass to the initializer. N� �����������r���z"max_workers must be greater than 0zinitializer must be a callableFzThreadPoolExecutor-%d)�min�os� cpu_count� ValueError�callable� TypeError�_max_workers�queue�SimpleQueue�_work_queue� threading� Semaphorer0����set�_threads�_brokenr����Lock�_shutdown_lock�_counter�_thread_name_prefix�_initializer� _initargs)r����max_workersZthread_name_prefixr3���r4���r ���r ���r���r���{���s$���� �zThreadPoolExecutor.__init__c������������� ���O���s����|�j����t�v�|�jrt|�j��|�jr,td��tr8td��t���}t||||�}|�j � |��|�����|W��d�����W��d�����S�1�s�0����Y��W�d�����n1�s�0����Y��d�S�)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdown)rO���r���rM���r8���r����RuntimeErrorr����Futurer���rH���r ����_adjust_thread_count)r���r���r���r����f�wr ���r ���r����submit����s���� zThreadPoolExecutor.submitc�����������������C���s����|�j�jdd�rd�S�|�jfdd�}t|�j�}||�jk�r�d|�jp>|�|f�}tj|t t �|�|�|�j|�j|�j fd�}|����|�j�|��|�jt|<�d�S�)Nr���)�timeoutc�����������������S���s���|��d���d�S�r���)r ���)�_r���r ���r ���r���� weakref_cb����s����z;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cbz%s_%d)�name�targetr���)r0����acquirerH����lenrL���rE���rQ���rI����Threadr7����weakref�refrR���rS����start�addr���)r���r]���Znum_threadsZthread_namer���r ���r ���r���rW�������s$���� � ��z'ThreadPoolExecutor._adjust_thread_countc�������������� ���C���st���|�j��Z�d|�_z|�j���}W�n�tjy4���Y�qRY�n0�|d�ur|j�t|�j���qW�d�����n1�sf0����Y��d�S�)NzBA thread initializer failed, the thread pool is not usable anymore) rO���rM���rH���� get_nowaitrF����Emptyr���r���r8���)r���r6���r ���r ���r���r.�������s���� z&ThreadPoolExecutor._initializer_failedTF)�cancel_futuresc������������� ���C���s����|�j��b�d|�_|rNz|�j���}W�n�tjy8���Y�qNY�n0�|d�ur|j����q|�j�d���W�d�����n1�sn0����Y��|r�|�j D�]}|� ���q�d�S�r���)rO���r���rH���rg���rF���rh���r����cancelr ���rL���r ���)r����waitri���r6���r���r ���r ���r����shutdown����s���� * zThreadPoolExecutor.shutdown)Nr;���Nr ���)T)r#���r$���r%���� itertools�count�__next__rP���r���rZ���r����Executorr9���rW���r.���rl���r ���r ���r ���r���r:���v���s��� ��� & r:���)r9���� __author__�concurrent.futuresr���rm���rF���rI���r'���rc���r@����WeakKeyDictionaryr���r���rN���r���r����_register_atexit�hasattrr���r`����_at_fork_reinitr1����objectr���r7����BrokenExecutorr8���rp���r:���r ���r ���r ���r����<module>���s,��� �+