PlasmaCalcs.tools.multiprocessing.TaskContainerCallKwargsAttrHaver

class PlasmaCalcs.tools.multiprocessing.TaskContainerCallKwargsAttrHaver

Bases: object

object with attrs corresponding to the main kwargs for TaskContainer.__call__.
This includes ncpu, timeout, and ncoarse.
It does not include kw, idx, reset, or skip_done.
__init__()

Methods

__init__()

check_pickle([x])

get_ncpu()

Attributes

ncoarse

ncpu

print_freq

print_freq_explicit

timeout

check_pickle(x=None)
checks that self (or, x, if provided) is pickleable, by pickling then unpickling.
Returns result of unpickling. Useful for debugging.
get_ncpu()
returns ncpu, but if None, return multiprocessing.cpu_count() instead.
(This is for convenience; using None will also work with any methods defined here.)
property ncoarse
int
if >1, group tasks into groups of size ncoarse before performing them.
property ncpu
None or int
max number of cpus to use for multiprocessing.
None –> use multiprocessing.cpu_count()
int –> use this value. if 0 or 1, do not use multiprocessing here.
Note: will actually use min(ncpu, number of calls to be made);
e.g. if ncpu=4 but len(arg_kw_tuples)=2, will only use 2 cpus.
see also: self.get_ncpu() to read actual number of cpus when self.ncpu is None.
property print_freq
None, or number (possibly negative or 0)
>0 –> Minimum number of seconds between progress updates.
=0 –> print every progress update.
<0 –> never print progress updates.
None –> use DEFAULTS.PROGRESS_UPDATES_PRINT_FREQ
property print_freq_explicit
like self.print_freq, but converts UNSET to value based on self.verbose,
UNSET –> result depends on self.verbose:
False or <=0 –> -1
True or (>=1 and <5) –> None
>=5 –> 0 (i.e. print every progress update)
if self.verbose doesn’t exist –> None
if result would be None, instead give DEFAULTS.PROGRESS_UPDATES_PRINT_FREQ.
property timeout
None or int
max duration, in seconds. Must be None or integer (due to limitations of signal.alarm method)
None –> no time limit.
Note: if time_limit is reached, will raise a TimeoutError and save the result so far.
(in this case, any not-yet-calculated values will each be RESULT_MISSING.)