pyVim.task ProgressUpdater sometimes throws
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
I'm new to this lib, so correct me if I'm wrong, because it might be me doing something stupid, not a bug :)
ProgressUpdaterand the defaultTaskUpdatesVerbosedepend directly ontask.info, instead on "snapshot" returned bypropertyCollector.WaitForUpdates. Thetask.infois volatile and can change now and then, which causes TOCTOU inTaskUpdatesVerbose
What I'm seeing (every few executions of a script that just reverts 1 VM to a snapshot and powers it on) is that TaskUpdatesVerbose throws when it tries to format info.progress using %d and info.progress happens to be None at that moment. At the same time info.progress somehow passes the first if and at that point it apparently claims to be an int.
- I've seen somewhere in docs that
task.infocan haveprogressnot set to anything (when task doesn't want to return percentage), if that's the case, the default logging will discard it, because it accepts only ints, which makes it not as verbose as advertised ;).
It seems to be true, because if I changed logging function to plain print("%s"...), that will happily stringify progress field, I've seen much more updates dumped to screen.
And in general, if I'm right that task.info is volatile and propertyCollector updates are stable, then the whole task code relies too much on task.info directly and works mostly because important fields happen to be immutable strings.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ProgressUpdater and the default TaskUpdatesVerbose, then trace how they read task.info versus snapshots from propertyCollector.WaitForUpdates. Reproduce the revert-and-power-on script and inspect the progress formatting path. Done means progress updates no longer intermittently raise when progress is None and the handling of unset progress matches the intended verbose behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100