Package entropy :: Module misc :: Class ParallelTask

Class ParallelTask

source code


Multithreading class that wraps Python threading.Thread. Specifically, this class makes possible to easily execute a function on a separate thread.

Python threads can't be stopped, paused or more generically arbitrarily controlled.

>>> from entropy.misc import ParallelTask
>>> parallel = ParallelTask(print, "hello world", 123)
>>> parallel.start()
hello world 123
>>> parallel.kill()
Instance Methods
 
__init__(self, *args, **kwargs)
ParallelTask constructor
source code
 
run(self)
This method is called automatically when start() is called.
source code
Python callable object
get_function(self)
Return the function passed to constructor that is going to be executed.
source code
Python object
get_rc(self)
Return result of the last parallel function call passed to constructor.
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, *args, **kwargs)
(Constructor)

source code 

ParallelTask constructor

Provide a function and its arguments as arguments of this constructor.

Overrides: object.__init__

run(self)

source code 

This method is called automatically when start() is called. Don't call this directly!!!

Overrides: threading.Thread.run

get_function(self)

source code 

Return the function passed to constructor that is going to be executed.

Returns: Python callable object
parallel function

get_rc(self)

source code 

Return result of the last parallel function call passed to constructor.

Returns: Python object
parallel function result