# circuits 2.1.0 documentation

# `circuits.core.workers` – Workers

Workers

Worker components used to perform “work” in independent threads or processes. Worker(s) are typically used by a Pool (circuits.core.pools) to create a pool of workers. Worker(s) are not registered with a Manager or another Component - instead they are managed by the Pool. If a Worker is used independently it should not be registered as it causes its main event handler `_on_task` to execute in the other thread blocking it.

## Classes

none

## Components

class `circuits.core.workers.``Worker`(*args, **kwargs)

  Bases: `circuits.core.components.BaseComponent`

  A thread/process Worker Component

  This Component creates a Worker (either a thread or process) which when given a `Task`, will execute the given function in the task in the background in its thread/process.

  Parameters: | process (bool) – True to start this Worker as a process (Thread otherwise)

  initializes x; see x.__class__.__doc__ for signature

## Events

class `circuits.core.workers.``Task`(f, *args, **kwargs)

  Bases: `circuits.core.events.Event`

  Task Event

  This Event is used to initiate a new task to be performed by a Worker or a Pool of Worker(s).

  Parameters: | f (function) – The function to be executed. args (tuple) – Arguments to pass to the function kwargs (dict) – Keyword Arguments to pass to the function

## Functions

none