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 theProgressReporter
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.
alphatwirl.progressbar.NullProgressMonitor module¶
alphatwirl.progressbar.ProgressBar module¶
alphatwirl.progressbar.ProgressMonitor module¶
alphatwirl.progressbar.ProgressPrint module¶
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
isNone
, 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
- name (str) – the name of the task. if
alphatwirl.progressbar.ProgressReportPickup module¶
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
orBProgressMonitor
, which, for example, uses the reports to updateProgressBar
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
orBProgressMonitor
), 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 monitorParameters: report (ProgressReport) – a progress report
-