Parallel iterator built using the fork() system call#

class sage.parallel.use_fork.WorkerData(input_value, starttime=None, failure='')[source]#

Bases: object

Simple class which stores data about a running p_iter_fork worker.

This just stores three attributes:

  • input: the input value used by this worker

  • starttime: the walltime when this worker started

  • failure: an optional message indicating the kind of failure

EXAMPLES:

sage: from sage.parallel.use_fork import WorkerData
sage: W = WorkerData(42); W
<sage.parallel.use_fork.WorkerData object at ...>
sage: W.starttime  # random
1499330252.463206
>>> from sage.all import *
>>> from sage.parallel.use_fork import WorkerData
>>> W = WorkerData(Integer(42)); W
<sage.parallel.use_fork.WorkerData object at ...>
>>> W.starttime  # random
1499330252.463206
class sage.parallel.use_fork.p_iter_fork(ncpus, timeout=0, verbose=False, reset_interfaces=True)[source]#

Bases: object

A parallel iterator implemented using fork().

INPUT:

  • ncpus – the maximal number of simultaneous

    subprocesses to spawn

  • timeout – (float, default: 0) wall time in seconds until

    a subprocess is automatically killed

  • verbose – (default: False) whether to print

    anything about what the iterator does (e.g., killing subprocesses)

  • reset_interfaces – (default: True) whether to reset

    all pexpect interfaces

EXAMPLES:

sage: X = sage.parallel.use_fork.p_iter_fork(2,3, False); X
<sage.parallel.use_fork.p_iter_fork object at ...>
sage: X.ncpus
2
sage: X.timeout
3.0
sage: X.verbose
False
>>> from sage.all import *
>>> X = sage.parallel.use_fork.p_iter_fork(Integer(2),Integer(3), False); X
<sage.parallel.use_fork.p_iter_fork object at ...>
>>> X.ncpus
2
>>> X.timeout
3.0
>>> X.verbose
False