Package mrv :: Module thread :: Class TerminatableThread
[hide private]
[frames] | no frames]

Class TerminatableThread

source code

        object --+        
                 |        
threading._Verbose --+    
                     |    
      threading.Thread --+
                         |
                        TerminatableThread
Known Subclasses:

A simple thread able to terminate itself on behalf of the user.

Terminate a thread as follows:

t.stop_and_join()

Derived classes call _should_terminate() to determine whether they should abort gracefully

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code

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

Inherited from threading.Thread (private): _set_daemon, _set_ident

Inherited from threading._Verbose (private): _note

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

    Subclass Interface
 
_should_terminate(self)
Returns: True if this thread should terminate its operation immediately
source code
 
_terminated(self)
Called once the thread terminated.
source code
 
start(self)
Start the thread and return self
source code
    Interface
 
schedule_termination(self)
Schedule this thread to be terminated as soon as possible.
source code
 
stop_and_join(self)
Ask the thread to stop its operation and wait for it to terminate :note: Depending on the implenetation, this might block a moment
source code
Properties [hide private]
  _terminate

Inherited from threading.Thread: daemon, ident, name

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

_should_terminate(self)

source code 
Returns:
True if this thread should terminate its operation immediately

_terminated(self)

source code 
Called once the thread terminated. Its called in the main thread
and may perform cleanup operations
:note: in the current implementation, this method will only be called if 
        the thread was stopped by ``stop_and_join``. If you have very important
        cleanup to do, you should do it before you exit your run method

start(self)

source code 
Start the thread and return self
Overrides: threading.Thread.start

schedule_termination(self)

source code 
Schedule this thread to be terminated as soon as possible. :note: this method does not block.