Current File : //usr/lib/python3/dist-packages/twisted/runner/test/__pycache__/test_procmon.cpython-312.pyc |
�
Ϫ�fd � �� � d Z ddlZddlmZmZmZ ddlmZ ddlm Z ddl
mZ ddlm
Z
ddlmZmZ dd lmZ G d
� d� Z G d� d
e e� Z G d� dej* � Z G d� dej. � Zy)z&
Tests for L{twisted.runner.procmon}.
� N)�ProcessDone�ProcessExitedAlready�ProcessTerminated)�Clock)�
MemoryReactor)�globalLogPublisher)�Failure)�LoggingProtocol�ProcessMonitor)�unittestc �8 � e Zd ZdZdZdZdZ dd�Zd� Zd� Z y)�DummyProcessa
An incomplete and fake L{IProcessTransport} implementation for testing how
L{ProcessMonitor} behaves when its monitored processes exit.
@ivar _terminationDelay: the delay in seconds after which the DummyProcess
will appear to exit when it receives a TERM signal
� Nc � � || _ || _ || _ || _ || _ || _ || _ || _ | | _ |
| _ y �N)
�proto�_reactor�_executable�_args�_environment�_path�_uid�_gid�_usePTY� _childFDs)�self�reactor�
executable�args�environment�pathr �uid�gid�usePTY�childFDss �B/usr/lib/python3/dist-packages/twisted/runner/test/test_procmon.py�__init__zDummyProcess.__init__ sL � � ��
���
�%�����
�'�����
��� ��� ����!��� c �� � | j dfdd�}| j �
t � �||v r5|| \ }}| j j || j
|� | _ yy)a�
A partial implementation of signalProcess which can only handle TERM and
KILL signals.
- When a TERM signal is given, the dummy process will appear to exit
after L{DummyProcess._terminationDelay} seconds with exit code 0
- When a KILL signal is given, the dummy process will appear to exit
immediately with exit code 1.
@param signalID: The signal name or number to be issued to the process.
@type signalID: C{str}
r �r r )�TERM�KILLN)�_terminationDelay�pidr r � callLater�processEnded�_signalHandler)r �signalID�params�delay�statuss r&