HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/application/runner/__pycache__/_runner.cpython-38.pyc
U


W[��@s�dZddlmZddlmZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZddlmZmZdd	lmZmZmZe	d
d�Gdd
�d
e��ZdS)z
Twisted application runner.
�)�stderr)�SIGTERM)�kill)�attrib�attrs�Factory)�globalLogBeginner�textFileLogObserver�FilteringLogObserver�LogLevelFilterPredicate�LogLevel�Logger�)�exit�
ExitStatus)�nonePIDFile�AlreadyRunningError�InvalidPIDFileErrorT)�frozenc@s�eZdZdZe�Ze�Zeed�Z	edd�Z
eejd�Z
eed�Zeed�Zedd�d�Zeee�d�Zedd�d�Zeee�d�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZdS)�Runnera�
    Twisted application runner.

    @cvar _log: The logger attached to this class.
    @type _log: L{Logger}

    @ivar _reactor: The reactor to start and run the application in.
    @type _reactor: L{IReactorCore}

    @ivar _pidFile: The file to store the running process ID in.
    @type _pidFile: L{IPIDFile}

    @ivar _kill: Whether this runner should kill an existing running
        instance of the application.
    @type _kill: L{bool}

    @ivar _defaultLogLevel: The default log level to start the logging
        system with.
    @type _defaultLogLevel: L{constantly.NamedConstant} from L{LogLevel}

    @ivar _logFile: A file stream to write logging output to.
    @type _logFile: writable file-like object

    @ivar _fileLogObserverFactory: A factory for the file log observer to
        use when starting the logging system.
    @type _pidFile: callable that takes a single writable file-like object
        argument and returns a L{twisted.logger.FileLogObserver}

    @ivar _whenRunning: Hook to call after the reactor is running;
        this is where the application code that relies on the reactor gets
        called.
    @type _whenRunning: callable that takes the keyword arguments specified
        by C{whenRunningArguments}

    @ivar _whenRunningArguments: Keyword arguments to pass to
        C{whenRunning} when it is called.
    @type _whenRunningArguments: L{dict}

    @ivar _reactorExited: Hook to call after the reactor exits.
    @type _reactorExited: callable that takes the keyword arguments
        specified by C{reactorExitedArguments}

    @ivar _reactorExitedArguments: Keyword arguments to pass to
        C{reactorExited} when it is called.
    @type _reactorExitedArguments: L{dict}
    )�defaultFcKsdS�N���_rr�D/usr/lib/python3/dist-packages/twisted/application/runner/_runner.py�<lambda>S�zRunner.<lambda>cKsdSrrrrrrrUrc	Csb|j}|��z,|�|��|��|��W5QRXWn"tk
r\ttjd�YdSXdS)z#
        Run this command.
        zAlready running.N)	�_pidFile�killIfRequested�startLogging�startReactor�
reactorExitedrrr�	EX_CONFIG)�self�pidFilerrr�runYsz
Runner.runcCs�|j}|jr�|tkr$ttjd�dSz|��}WnBtk
rRttjd�YdSt	k
rrttj
d�YdSX|��|jj
d|d�t|t�ttj�dSdS)zj
        If C{self._kill} is true, attempt to kill a running instance of the
        application.
        zNo PID file specified.NzUnable to read PID file.zInvalid PID file.zTerminating process: {pid})�pid)r�_killrrr�EX_USAGE�read�EnvironmentError�EX_IOERRr�
EX_DATAERRr �_log�inforr�EX_OK)r$r%r'rrrrls$

zRunner.killIfRequestedcCs<|j}|j}||�}t|jd�}t||g�}t�|g�dS)z=
        Start the L{twisted.logger} logging system.
        )ZdefaultLogLevelN)�_logFile�_fileLogObserverFactoryr�_defaultLogLevelr
rZbeginLoggingTo)r$ZlogFileZfileLogObserverFactoryZfileLogObserverZlogLevelPredicateZfilteringObserverrrrr �s��zRunner.startLoggingcCs(|j�|j�|j�d�|j��dS)z�
        Register C{self._whenRunning} with the reactor so that it is called
        once the reactor is running, then start the reactor.
        zStarting reactor...N)�_reactorZcallWhenRunning�whenRunningr.r/r&�r$rrrr!�szRunner.startReactorcCs|jf|j�dS)z�
        Call C{self._whenRunning} with C{self._whenRunningArguments}.

        @note: This method is called after the reactor starts running.
        N)�_whenRunning�_whenRunningArgumentsr6rrrr5�szRunner.whenRunningcCs|jf|j�dS)z�
        Call C{self._reactorExited} with C{self._reactorExitedArguments}.

        @note: This method is called after the reactor exits.
        N)�_reactorExited�_reactorExitedArgumentsr6rrrr"�szRunner.reactorExitedN)�__name__�
__module__�__qualname__�__doc__r
r.rr4rrr(rr/r3rr1r	r2r7r�dictr8r9r:r&rr r!r5r"rrrrrs$/



	rN)r>�sysr�signalr�osr�attrrrrZtwisted.loggerrr	r
rrr
�_exitrrZ_pidfilerrr�objectrrrrr�<module>s