Merge lp:~jderose/filestore/callback into lp:filestore
Status: | Merged |
---|---|
Merged at revision: | 230 |
Proposed branch: | lp:~jderose/filestore/callback |
Merge into: | lp:filestore |
Diff against target: |
161 lines (+90/-1) 2 files modified
filestore.py (+18/-1) test_filestore.py (+72/-0) |
To merge this branch: | bzr merge lp:~jderose/filestore/callback |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Jordan | Approve | ||
Review via email:
|
Description of the change
This changes batch_import_iter() to take an optional keyword-only `callback` argument. The callback takes 2 arguments:
def callback(count, size):
pass
That's the completed count, and the completed bytes. The callback is called at the end of processing each file, plus whenever the next 128 MiB (16 leaves) have been completed in a large file and at least one more leaf remains.
For example, say you have a batch with one file and the file is exactly 33 leaves in size (264 MiB). The callback would be called 3 times, like this:
callback(0, 128 * MiB)
callback(0, 256 * MiB)
callback(1, 264 * MiB)
Updating the progress every 128 MiB is probably about right as far as reassuring the user, but we should play with it a bit if it seems too infrequent or unnecessarily frequent.
Looks good. I'm glad to see this UX issue fixed.