subprocess2
index

  python-subprocess2
 
Copyright (c) 2015 Timothy Savannah LGPL All rights reserved. See LICENSE file for more details.
 
This module provides extensions to the standard "subprocess" module
Importing this module modifies the global subprocess module. You can use it like:
 
  from subprocess2 import Popen
 
or
 
  import subprocess2
 
  from subprocess import Popen

 
Package Contents
       
BackgroundTask

 
Classes
       
__builtin__.object
subprocess.Popen
exceptions.Exception(exceptions.BaseException)

 
class Popen(__builtin__.object)
     Methods defined here:
runInBackground(self, pollInterval=0.1)
runInBackground - Create a background thread which will manage this process, automatically read from streams, and perform any cleanups
 
  The object returned is a "BackgroundTaskInfo" object, and represents the state of the process. It is updated automatically as the program runs,
    and if stdout or stderr are streams, they are automatically read from and populated into this object.
 
 @see BackgroundTaskInfo for more info or 
 
@param pollInterval - Amount of idle time between polling
wait(self)
Wait for child process to terminate.  Returns returncode
attribute.
waitOrTerminate(self, timeoutSeconds, pollInterval=0.05, terminateToKillSeconds=1.5)
waitOrTerminate - Wait up to a certain number of seconds for the process to end.
 
    If the process is running after the timeout has been exceeded, a SIGTERM will be sent. 
    Optionally, an additional SIGKILL can be sent after some configurable interval. See #terminateToKillSeconds doc below
 
    @param timeoutSeconds <float> - Number of seconds to wait
 
    @param pollInterval <float> (default .05)- Number of seconds between each poll
 
    @param terminateToKillSeconds <float/None> (default 1.5) - If application does not end before #timeoutSeconds , terminate() will be called.
 
        * If this is set to None, an additional #pollInterval sleep will occur after calling .terminate, to allow the application to cleanup. returnCode will be return of app if finished, or None if did not complete.
        * If this is set to 0, no terminate signal will be sent, but directly to kill. Because the application cannot trap this, returnCode will be None.
        * If this is set to > 0, that number of seconds maximum will be given between .terminate and .kill. If the application does not terminate before KILL, returnCode will be None.
 
    Windows Note -- On windows SIGTERM and SIGKILL are the same thing.
 
    @return dict { 'returnCode' : <int or None> , 'actionTaken' : <int mask of SUBPROCESS2_PROCESS_*> }
        Returns a dict representing results: 
            "returnCode" matches return of application, or None per #terminateToKillSeconds doc above.
            "actionTaken" is a mask of the SUBPROCESS2_PROCESS_* variables. If app completed normally, it will be SUBPROCESS2_PROCESS_COMPLETED, otherwise some mask of SUBPROCESS2_PROCESS_TERMINATED and/or SUBPROCESS2_PROCESS_KILLED
waitUpTo(self, timeoutSeconds, pollInterval=0.05)
Popen.waitUpTo - Wait up to a certain number of seconds for the process to end.
 
    @param timeoutSeconds <float> - Number of seconds to wait
 
    @param pollInterval <float> (default .05) - Number of seconds in between each poll
 
    @return - Returncode of application, or None if did not terminate.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        DEFAULT_POLL_INTERVAL = 0.05
PIPE = -1
STDOUT = -2
SUBPROCESS2_DEFAULT_TERMINATE_TO_KILL_SECONDS = 1.5
SUBPROCESS2_PROCESS_COMPLETED = 0
SUBPROCESS2_PROCESS_KILLED = 2
SUBPROCESS2_PROCESS_TERMINATED = 1
__all__ = ['subprocess2_version_str', 'check_output', 'SUBPROCESS2_PROCESS_TERMINATED', 'STDOUT', 'SUBPROCESS2_PROCESS_KILLED', 'Popen', 'DEFAULT_POLL_INTERVAL', 'subprocess2_version', 'PIPE', 'SUBPROCESS2_DEFAULT_TERMINATE_TO_KILL_SECONDS', 'call', 'check_call', 'CalledProcessError', 'SUBPROCESS2_PROCESS_COMPLETED']
subprocess2_version = (0, 1, 2)
subprocess2_version_str = '0.1.2'