Child Pool Module sw.pool

Classes

class sw.pool.Pool(func, file, kwargs)[source]

Stores parameters across all children, sets out log directory, initializes our data arrays, records start times, and pops numJobs functions into a Queue. Abstracts and makes it easier to manage scores of child processes. Also has a think() process to continuously manage them.

Parameters:
  • func – The function reference that will be put into our work queue numJobs times.
  • file – Filename with directory of our script which contained func. This is used to create a relative log directory.
  • kwargs – Kwargs dict passed to main(), eventually passes arguments on to GhostDriver. ‘stagger’ is pulled from this dict if it exists.
Returns:

Pool (self)

done()[source]

Returns a True/False if the pool is done processing jobs. Called continuously by our main loop. When False, the program terminates.

Returns:Boolean for if there are children still running work.
endChild(i=None)[source]

Removes the last created child, called by GUI.

Parameters:i (None) – The index of the child process to kill. If not specified, it chooses the last child in the pool.children array that is alive.
Returns:None
failed()[source]

Reports failed jobs so far.

Returns:Integer for number of failed jobs.
logMsg(msg, level=0)[source]

Logs a message to our log file in a consistent format. Depends on pool.lh already being initialized and ready for writing. Does not flush the handle.

Parameters:
  • msg – The message to be logged.
  • level (NOTICE) – The level of the message included. If the level is not greater than or equal to the user-specified level, the message is discarded.
Returns:

None

newChild()[source]

Creates a new child which will in turn start itself.

Returns:None
start()[source]

Restarts a pool after it’s been stop( )ed.

Returns:None
stop(type=3)[source]
Stops the pool cleanly and terminates all the children in it.
Currently handles pausing too until I need special functionality.
Parameters:type (STOPPED) – Type of stopping this is, either pausing or stopping.
Returns:None
successful()[source]

Reports the number of jobs successfully completed so far.

Returns:Integer for number of jobs successfully completed.
think()[source]

Runs through a single think loop; called by sw.wrapper.mainLoop() until there is no more work remaining. Check children are alive/restart if there are more jobs. Checks queues and parses any data.

Returns:None
timeTaken(sum=False)[source]

Reports how long everything has taken so far.

Parameters:sum (False) – Whether or not to return the sum of the time taken on jobs.
Returns:List of individual job run times if sum is False, otherwise the amount of time taken as a float.

Table Of Contents

Previous topic

Wrapper Module sw.wrapper

Next topic

Child Module sw.child

This Page