Package roslaunch :: Module pmon :: Class ProcessMonitor
[frames] | no frames]

Class ProcessMonitor

source code

        object --+        
                 |        
threading._Verbose --+    
                     |    
      threading.Thread --+
                         |
                        ProcessMonitor

Instance Methods
 
__init__(self, name='ProcessMonitor')
This constructor should always be called with keyword arguments.
source code
 
add_process_listener(self, l)
Listener for process events.
source code
 
register(self, p)
Register process with ProcessMonitor
source code
 
register_core_proc(self, p)
Register core process with ProcessMonitor.
source code
 
registrations_complete(self)
Inform the process monitor that registrations are complete.
source code
 
unregister(self, p) source code
bool
has_process(self, name)
Returns: True if process is still be monitored.
source code
Process
get_process(self, name)
Returns: process registered under  name, or None
source code
bool
has_main_thread_jobs(self)
Returns: True if ProcessMonitor has tasks that need to be run in the main thread
source code
 
do_main_thread_jobs(self)
Execute tasks that need to be run in the main thread.
source code
bool
kill_process(self, name)
Kill process that matches name.
source code
 
shutdown(self)
Shutdown the process monitor thread
source code
 
get_active_names(self) source code
[[(str, int),], [(str,int),]]
get_process_names_with_spawn_count(self)
Returns: Two lists, where first list of active process names along with the number of times that process has been spawned.
source code
 
mainthread_spin_once(self)
run() occurs in a separate thread and cannot do certain signal-related work.
source code
 
mainthread_spin(self)
run() occurs in a separate thread and cannot do certain signal-related work.
source code
 
run(self)
thread routine of the process monitor.
source code

Inherited from threading.Thread: __repr__, getName, isAlive, isDaemon, is_alive, join, setDaemon, setName, start

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from threading.Thread: daemon, ident, name

Inherited from object: __class__

Method Details

__init__(self, name='ProcessMonitor')
(Constructor)

source code 

This constructor should always be called with keyword arguments. Arguments are:

*group* should be None; reserved for future extension when a ThreadGroup class is implemented.

*target* is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

*name* is the thread name. By default, a unique name is constructed of the form "Thread-N" where N is a small decimal number.

*args* is the argument tuple for the target invocation. Defaults to ().

*kwargs* is a dictionary of keyword arguments for the target invocation. Defaults to {}.

If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.

Overrides: object.__init__
(inherited documentation)

add_process_listener(self, l)

source code 

Listener for process events. MUST be called before ProcessMonitor is running.See ProcessListener class.

Parameters:

register(self, p)

source code 

Register process with ProcessMonitor

Parameters:
Raises:
  • RLException - if process with same name is already registered

register_core_proc(self, p)

source code 

Register core process with ProcessMonitor. Coreprocesses have special shutdown semantics. They are killed after all other processes, in reverse order in which they are added. @param p Process

Parameters:
Raises:
  • RLException - if process with same name is already registered

registrations_complete(self)

source code 

Inform the process monitor that registrations are complete. After the registrations_complete flag is set, process monitor will exit if there are no processes left to monitor.

has_process(self, name)

source code 
Returns: bool
True if process is still be monitored. If False, process has died or was never registered with process

get_process(self, name)

source code 
Returns: Process
process registered under  name, or None

has_main_thread_jobs(self)

source code 
Returns: bool
True if ProcessMonitor has tasks that need to be run in the main thread

do_main_thread_jobs(self)

source code 

Execute tasks that need to be run in the main thread. Must be called from main thread.

kill_process(self, name)

source code 

Kill process that matches name. NOTE: a killed process will continue to show up as active until the process monitor thread has caught that it has died.

Parameters:
  • name (str) - Process name
Returns: bool
True if a process named name was removed from process monitor. A process is considered killed if its stop() method was called.

get_process_names_with_spawn_count(self)

source code 
Returns: [[(str, int),], [(str,int),]]
Two lists, where first list of active process names along with the number of times that process has been spawned. Second list contains dead process names and their spawn count.

mainthread_spin_once(self)

source code 

run() occurs in a separate thread and cannot do certain signal-related work. The main thread of the application must call mainthread_spin() or mainthread_spin_once() in order to perform these jobs.

mainthread_spin(self)

source code 

run() occurs in a separate thread and cannot do certain signal-related work. The main thread of the application must call mainthread_spin() or mainthread_spin_once() in order to perform these jobs. mainthread_spin() blocks until the process monitor is complete.

run(self)

source code 

thread routine of the process monitor. NOTE: you must still call mainthread_spin or mainthread_spin_once() from the main thread in order to pick up main thread work from the process monitor.

Overrides: threading.Thread.run