Package ganeti :: Module workerpool :: Class BaseWorker
[hide private]
[frames] | no frames]

Class BaseWorker

source code


Base worker class for worker pools.

Users of a worker pool must override RunTask in a subclass.

Instance Methods [hide private]
 
__init__(self, pool, worker_id)
Constructor for BaseWorker thread.
source code
 
ShouldTerminate(self)
Returns whether this worker should terminate.
source code
 
GetCurrentPriority(self)
Returns the priority of the current task.
source code
 
SetTaskName(self, taskname)
Sets the name of the current task.
source code
 
_HasRunningTaskUnlocked(self)
Returns whether this worker is currently running a task.
source code
 
_GetCurrentOrderAndTaskId(self)
Returns the order and task ID of the current task.
source code
 
run(self)
Main thread function.
source code
 
RunTask(self, *args)
Function called to start a task.
source code

Inherited from threading.Thread: __repr__, daemon, getName, ident, isAlive, isDaemon, is_alive, join, name, setDaemon, setName, start

Inherited from threading.Thread (private): _block, _reset_internal_locks, _set_daemon, _set_ident

Inherited from threading._Verbose (private): _note

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, pool, worker_id)
(Constructor)

source code 

Constructor for BaseWorker thread.

Parameters:
  • pool - the parent worker pool
  • worker_id - identifier for this worker
Overrides: object.__init__

ShouldTerminate(self)

source code 

Returns whether this worker should terminate.

Should only be called from within RunTask.

GetCurrentPriority(self)

source code 

Returns the priority of the current task.

Should only be called from within RunTask.

SetTaskName(self, taskname)

source code 

Sets the name of the current task.

Should only be called from within RunTask.

Parameters:
  • taskname (string) - Task's name

_GetCurrentOrderAndTaskId(self)

source code 

Returns the order and task ID of the current task.

Should only be called from within RunTask.

run(self)

source code 

Main thread function.

Waits for new tasks to show up in the queue.

Overrides: threading.Thread.run

RunTask(self, *args)

source code 

Function called to start a task.

This needs to be implemented by child classes.