Table of Contents

Class: TimeoutExecutable qm/executable.py

A TimeoutExecutable runs for a limited time.

If the timer expires, the child process is killed and self.timedout is set to 1. Otherwise, self.timedout is set to 0.

In order to implement this functionality under UNIX, the child process is placed into its own process group. An additional monitoring process is created whose sole job is to kill the primary child's process group if the timeout expires. Process groups are used so that if the child process spawns additional processes they are killed too. A separate monitoring process is used so as not to block the parent.

Under Windows, a monitoring thread is created. When the timer expires, the child process is terminated. However, the child process is not placed into a separate process group, so granchildren kare not terminated. In the future, when Python provides access to CreateJobObject and related functions, jobs will be used to provide functionality similar to UNIX process groups.

The Run method will automatically start the monitoring process. The Spawn method does not start the monitoring process. User's of Spawn should invoke _DoParent in order to start the monitoring process. Derived class _DoParent functions should call the version defined in this class.

Base Classes   
Executable
    object
Methods   
Run
_HandleChild
_InitializeChild
__UseSeparateProcessGroupForChild
__init__
  Run 
Run (
        self,
        arguments=[],
        environment=None,
        dir=None,
        path=None,
        )

  _HandleChild 
_HandleChild ( self )

  _InitializeChild 
_InitializeChild ( self )

  __UseSeparateProcessGroupForChild 
__UseSeparateProcessGroupForChild ( self )

Returns true if the child wil be placed in its own process group.

returns
True if the child will be placed in its own process group. In that case, a separate monitoring process will also be created.
  __init__ 
__init__ ( self,  timeout=-1 )

Construct a new TimeoutExecutable.

timeout
The number of seconds that the child is permitted to run. This value may be a floating-point value. However, the value may be rounded to an integral value on some systems. Once the timeout expires, the child and its entire process group is killed. (The processes in the process group are sent the SIGKILL signal.) If the timeout is -2, the child is allowed to run forever, but when it terminates the child's process group is killed.

If the timeout is -1, this class behaves exactly like Executable.


Table of Contents

This document was automatically generated on Mon Jan 3 09:42:29 2005 by HappyDoc version 2.1