alphatwirl.progressbar package

Submodules

alphatwirl.progressbar.BProgressMonitor module

class alphatwirl.progressbar.BProgressMonitor.BProgressMonitor(presentation)[source]

Bases: object

A progress monitor of tasks.

This class monitors the progress of tasks and present it.

Tasks can be concurrently executed. The progress can be presented in an arbitrary way specified at the initialization.

This class monitors the progress and present it in the background by using ProgressReportPickup.

In order for a progress to be monitored by this class, an object that executes a task needs to send the ProgressReport through the ProgressReporter created by this class.

Examples

A presentation method needs to be specified at the initialization. For example, to use ProgressBar:

presentation = ProgressBar()
monitor = BProgressMonitor(presentation)

After the initialization, start monitoring:

monitor.begin()

Then, create as many reporters (ProgressReporter) as the number of the tasks whose progresses need to be monitored:

reporter1 = monitor.createReporter()
reporter2 = monitor.createReporter()
reporter3 = monitor.createReporter()

These reporters can be given to objects which execute the tasks. These objects can be in other processes as long as the reporters are properly passed to them.

If a ProgressReport is given to these reporters:

reporter1.report(report)

the report will be received by ProgressReportPickup, which will use the report to present the progress in the way specified.

When all tasks are finished, end monitoring:

monitor.end()

This will ends ProgressReportPickup, which is running in a different process.

begin()[source]
end()[source]
createReporter()[source]

alphatwirl.progressbar.NullProgressMonitor module

class alphatwirl.progressbar.NullProgressMonitor.NullProgressMonitor[source]

Bases: object

createReporter()[source]
begin()[source]
end()[source]

alphatwirl.progressbar.ProgressBar module

class alphatwirl.progressbar.ProgressBar.ProgressBar[source]

Bases: object

nreports()[source]
present(report)[source]
createLine(report)[source]

alphatwirl.progressbar.ProgressMonitor module

class alphatwirl.progressbar.ProgressMonitor.Queue(presentation)[source]

Bases: object

put(report)[source]
class alphatwirl.progressbar.ProgressMonitor.ProgressMonitor(presentation)[source]

Bases: object

begin()[source]
end()[source]
createReporter()[source]

alphatwirl.progressbar.ProgressPrint module

class alphatwirl.progressbar.ProgressPrint.ProgressPrint[source]

Bases: object

nreports()[source]
present(report)[source]
createLine(report)[source]

alphatwirl.progressbar.ProgressReport module

class alphatwirl.progressbar.ProgressReport.ProgressReport(name, done, total, taskid=None)[source]

Bases: object

A progress report

Parameters:
  • name (str) – the name of the task. if taskid is None, used to identify the task
  • done (int) – the number of the iterations done so far
  • total (int) – the total iterations to be done
  • taskid (immutable, optional) – if given, used to identify the task. useful if multiple tasks have the same name
last()[source]
first()[source]

alphatwirl.progressbar.ProgressReportPickup module

class alphatwirl.progressbar.ProgressReportPickup.ProgressReportPickup(queue, presentation)[source]

Bases: multiprocessing.process.Process

run()[source]

alphatwirl.progressbar.ProgressReporter module

class alphatwirl.progressbar.ProgressReporter.ProgressReporter(queue)[source]

Bases: object

A progress reporter

This class sends a ProgressReport to a progress monitor, e.g., ProgressMonitor or BProgressMonitor, which, for example, uses the reports to update ProgressBar on the screen.

An instance of this class is initialized with a message queue:

reporter = ProgressReporter(queue)

A reporter, an instance of this class, is typically created and initialized by a progress monitor (ProgressMonitor or BProgressMonitor), which keeps the other end of the message queue. A reporter and a monitor might be running in different processes.

A report, an instance of ProgressReport, can be sent as:

reporter.report(report)

This method can be frequently called multiple times. However, after sending one report, the reporter wait for a certain interval (0.1 seconds by default) before sending another report. Reports received within this interval will be discarded. The exception for this is the last report. The last report, which indicates the completion of the task, will be always sent to the progress monitor regardless of whether it is given within the interval.

report(report)[source]

send report to a progress monitor

Parameters:report (ProgressReport) – a progress report

Module contents