The timeoutpool tools

API

class timeoutpool.TimeoutPool(n_jobs=1, timeout=-1)[source]

A pool object being able to run n_jobs workers each subject to time-out to process a list of tasks

__init__(n_jobs=1, timeout=-1)[source]

The constructor of the object

Parameters
  • n_jobs (int) – the number of parallel jobs

  • timeout (float/None) – the timeout time in seconds, None/negative means no time-out

apply(function, jobs)[source]

apply-style interface of the pool object: applying a function to a list of jobs

Parameters
  • function (callable) – the function to be executed

  • jobs (list) – the list of arguments the function is executed with

Returns

the results of the job execution

Return type

list

execute(jobs)[source]

Execute the jobs parallel with time-out.

Parameters

jobs (list/generator) – the list or generator of jobs to be executed

Returns

the list of results

Return type

list

class timeoutpool.TimeoutJobBase[source]

Preferred base class of a TimeoutJob

__init__()
execute()[source]

Execute the job

Returns

the result of the job

Return type

obj

timeout()[source]

Executes the timeout clean-up

Returns

the result of the timeout clean-up

Return type

obj