garage.sampler.stateful_pool module

class SharedGlobal[source]

Bases: object

class StatefulPool[source]

Bases: object

close()[source]
initialize(n_parallel)[source]
run_collect(collect_once, threshold, args=None, show_prog_bar=True)[source]

Run the collector method using the worker pool. The collect_once method will receive ‘g’ as its first argument, followed by the provided args, if any. The method should return a pair of values. The first should be the object to be collected, and the second is the increment to be added. This will continue until the total increment reaches or exceeds the given threshold.

Sample script:

def collect_once(g):
return ‘a’, 1

stateful_pool.run_collect(collect_once, threshold=3) # should return [‘a’, ‘a’, ‘a’]

Parameters:
  • collector
  • threshold
Returns:

run_each(runner, args_list=None)[source]

Run the method on each worker process, and collect the result of execution.

The runner method will receive ‘g’ as its first argument, followed by the arguments in the args_list, if any :return:

run_imap_unordered(runner, args_list)[source]
run_map(runner, args_list)[source]