| |
- Exception
- IdPrinter
- Parallelizer
- PipeReader
- Reporter
-
- LogReporter
- TerminalReporter
class LogReporter(Reporter) |
|
A reporter that prints out status line-by-line. |
|
- abort(self, pid, item)
- begin(self, pid, item)
- cleanup(self)
- exit(self, pid)
- fail(self, pid, item, exception)
- init(self, children)
- spawn(self, pid)
- success(self, pid, item, result)
|
class Parallelizer |
|
Class for maintaining the state of work being done in parallel.
Usually, the parallelize() function in this module is sufficient; if
you want to use this class directly, then:
1. Create a Parallelizer object by passing in the work
function and the optional Reporter object to the
Parallelizer() constructor.
2. Call the 'spawn(children)' method to spawn the specified
number of child processes.
3. Call the 'process(items)' method with a list of items to
process. You can do this as many times as you want.
4. Be sure to call the 'cleanup()' method to clean away the
child processes when you are done.
5. Repeat steps 2 through 4 if you want to spawn more
children and collect more results. The results accrue
in a dictionary in the 'results' attribute. |
|
- __init__(self, function, reporter=<delegate.Reporter instance>)
- child(self, reader, writer)
- cleanup(self)
- process(self, items)
- spawn(self, children)
|
class Reporter |
|
Abstract base class for Reporter objects. To handle callbacks
during processing, declare your own Reporter object that implements
these methods. |
|
- abort(self, pid, item)
- Called by the Parallelizer when a child terminates unexpectedly.
- begin(self, pid, item)
- Called by the Parallelizer when a child starts work on an item.
- cleanup(self)
- Called by the Parallelizer when child processes are cleaned up.
- exit(self, pid)
- Called by the Parallelizer when a child terminates.
- fail(self, pid, item, exception)
- Called by the Parallelizer when a child raises an exception.
- init(self, children)
- Called by the Parallelizer just before processes are spawned.
- spawn(self, pid)
- Called by the Parallelizer for each individual child spawned.
- success(self, pid, item, result)
- Called by the Parallelizer when a child produces a result.
|
class TerminalReporter(Reporter) |
|
A reporter that displays animated status on an ANSI terminal. |
|
- abort(self, pid, item)
- begin(self, pid, item)
- cleanup(self)
- exit(self, pid)
- fail(self, pid, item, exception)
- init(self, children)
- spawn(self, pid)
- success(self, pid, item, result)
| |