accelmo.fitting.pool

A pool of worker processes and the parent-side state kept for each one.

class accelmo.fitting.pool.MetadataT

What the fitter keeps about each worker (tracking: its runtime metadata).

alias of TypeVar(‘MetadataT’)

class accelmo.fitting.pool.WorkerPool[MetadataT](conns=list(), workers=list(), metadata=list(), particle_counts=list())[source]

Bases: Generic[MetadataT]

Worker processes, their pipes and, for tracking workers, their metadata.

metadata and particle_counts are parallel to workers when filled; pools whose workers need neither (closed-twiss) leave them empty.

Parameters:
  • conns (list[Connection])

  • workers (list[mp.Process])

  • metadata (list[MetadataT])

  • particle_counts (list[int])

conns: list[Connection]
workers: list[Process]
metadata: list[MetadataT]
particle_counts: list[int]
spawn(worker_class, worker_id, *args)[source]

Start worker_class(child_conn, worker_id, *args) and return the parent pipe end.

Return type:

Connection

Parameters:
  • worker_class (Callable[..., mp.Process])

  • worker_id (int)

  • args (object)

property channels: WorkerChannels

Channels over every worker in the pool.

stop()[source]

Send STOP, join (forcing stragglers) and close the pipes.

Return type:

None

kill()[source]

Terminate every worker without waiting for it to respond.

Return type:

None