Package gmisclib :: Module threaded_io :: Class Thread_poolR
[frames] | no frames]

Class Thread_poolR

source code


Here, you have a pool of n threads. You can call x.start(function, args, kwargs) to start something running (perhaps a write to a file), and then go off and compute something else while the I/O completes. If you need to wait for completion, call x.join().

This class is designed to return values from the function via get() or getany().

Nested Classes
  CaughtException (Inherited from gmisclib.threaded_io.Thread_pool)
  EOF (Inherited from gmisclib.threaded_io.Thread_pool)
Instance Methods
 
__init__(self, n=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
start(self, tag, fn, args=None, kwargs=None) source code
a tuple(whatever, whatever) pair from a computation or a CaughtException
getany(self)
Returns: the first available answer, as a (tag, value) pair.
source code
whatever or a CaughtException
get(self, tag) source code
 
has_answer(self)
Is there an answer ready?
source code
 
__del__(self) (Inherited from gmisclib.threaded_io.Thread_pool) source code
 
__len__(self) (Inherited from gmisclib.threaded_io.Thread_pool) source code
 
join(self) (Inherited from gmisclib.threaded_io.Thread_pool) source code
 
startNR(self, target=None, args=None, kwargs=None) (Inherited from gmisclib.threaded_io.Thread_pool) source code
 
startQ(self, queue, tag, target=None, args=None, kwargs=None) (Inherited from gmisclib.threaded_io.Thread_pool) source code
 
startRV(self, target=None, args=None, kwargs=None) (Inherited from gmisclib.threaded_io.Thread_pool) source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, n=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

getany(self)

source code 
Returns: a tuple(whatever, whatever) pair from a computation or a CaughtException
the first available answer, as a (tag, value) pair. The tag was set in the call to start and the value is the result of the computation. If the computation raised an exectption, getany will return a CaughtException object instead.