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.

Methods

check_pickle([x])

checks that self (or, x, if provided) is pickleable, by pickling then unpickling.

get_ncpu()

returns ncpu, but if None, return multiprocessing.cpu_count() instead.

_default_ncoarse()

returns default for ncoarse.

_default_ncpu()

returns default for ncpu.

_default_print_freq()

returns default for print_freq.

_default_timeout()

returns default for timeout.

Attributes

ncoarse

int

ncpu

None or int

print_freq

None, or number (possibly negative or 0)

print_freq_explicit

like self.print_freq, but converts UNSET to value based on self.verbose,

timeout

None or int

_default_ncoarse()

returns default for ncoarse. Here, returns 1; i.e., do not group tasks.

_default_ncpu()

returns default for ncpu. Here, returns None; i.e., use multiprocessing.cpu_count().

_default_print_freq()

returns default for print_freq. Here, returns UNSET; i.e., infer from self.verbose.

(See self.print_freq_explicit to get the actual value of print_freq.)
_default_timeout()

returns default for timeout. Here, returns None; i.e., no time limit.

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.)