@@ -25,15 +25,33 @@ throttling rate than deterministic ones.
2525
2626Below are examples in Python for deterministic and non-deterministic progresses.
2727
28- deterministic_progress = lldb.SBProgress('Deterministic Progress', 'Detail', 3, lldb.SBDebugger)
29- for i in range(3):
30- deterministic_progress.Increment(1, f'Update {i}')
28+ deterministic_progress1 = lldb.SBProgress('Deterministic Progress', 'Detail', 3, lldb.SBDebugger)
29+ for i in range(3):
30+ deterministic_progress1.Increment(1, f'Update {i}')
31+
32+ # The call to Finalize() is a no-op as we already incremented the right amount of
33+ # times and caused the end event to be sent.
34+ deterministic_progress1.Finalize()
35+ deterministic_progress2 = lldb.SBProgress('Deterministic Progress', 'Detail', 10, lldb.SBDebugger)
36+ for i in range(3):
37+ deterministic_progress2.Increment(1, f'Update {i}')
38+
39+ # Cause the progress end event to be sent even if we didn't increment the right
40+ # number of times. Real world examples would be in a try-finally block to ensure
41+ # progress clean-up.
42+
43+ deterministic_progress2.Finalize()
44+ If you don't call Finalize() when the progress is not done, the progress object will eventually get
45+ garbage collected by the Python runtime, the end event will eventually get sent, but it is best not to
46+ rely on the garbage collection when using lldb.SBProgress.
47+
48+ Non-deterministic progresses behave the same, but omit the total in the constructor.
3149
3250 non_deterministic_progress = lldb.SBProgress('Non deterministic progress, 'Detail', lldb.SBDebugger)
3351 for i in range(10):
3452 non_deterministic_progress.Increment(1)
35-
36- # Explicitly send a progressEnd from Python .
53+ # Explicitly send a progressEnd, otherwise this will be sent
54+ # when the python runtime cleans up this object .
3755 non_deterministic_progress.Finalize()
3856" ) lldb::SBProgress;
3957
0 commit comments