[MERGE] Add exit() on progressbars from TestUIFactory
mbp at sourcefrog.net
Fri Mar 13 07:13:27 GMT 2009
"[Generators], cause of and solution to so many of life's problems."
Some of the most interesting loops to show progress bars are in
generators, because we try to stream through processing large data.
The problem is that python2.4 does not let you put finally blocks in
generators. If you allocate the pb and finish it outside the generator,
then the pb won't finish until the data is all consumed, when we'd
actually like it to finish when the generator finishes.
This adds a new pb.exit() routine you can call from finally, so that the
recommended method is for these generators to finish the pb themselves.
So in the normal case it will disappear at the right time, and if an
exception is raised it will still get closed.
It's called exit() for similarity with the name used by ``with`` blocks in
python2.6. close is not quite right because you can't close twice and
this might be a generally useful pattern.
This avoids needing to separately catch except too.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 7279 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090313/ece0416e/attachment.bin
More information about the bazaar