mirror of
https://github.com/Corsinvest/cv4pve-api-powershell.git
synced 2026-04-25 12:15:48 +03:00
[GH-ISSUE #51] Wait-PveTaskIsFinish is extremely inefficient #31
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/cv4pve-api-powershell#31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @r3st0r3 on GitHub (Feb 20, 2026).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/51
What happened?
The function Wait-PveTaskIsFinish uses a while-loop to wait for the finishing of a PVE-Task. It does so without using Start-Sleep. Instead it polls [DateTime]::Now every few milliseconds and checks if waittime until next API-Call is done yet. This leads to 100% cpu usage on the pwsh process used.
Expected behavior
You shoud use Start-Sleep to sleep (without heavy cpu-usage) between two while-loop-runs.
Relevant log output
Proxmox VE Version
9.1
Module Version
9.1.2
PowerShell Version
7.4.13
Version (working)
No response
On what operating system are you experiencing the issue?
Windows
Pull Request
@r3st0r3 commented on GitHub (Feb 20, 2026):
See Pull Request #52
@r3st0r3 commented on GitHub (Feb 20, 2026):
You could also include a Function showing a Powershell Progressbar while waiting for longer tasks (like moving a disk). I build a working example in my fork, could make a pull request for this also.
Examples:
Usage like Wait-PveTaskIsFinish without extra parameters (using defaults)
Usage with extra parameters
@franklupo commented on GitHub (Feb 24, 2026):
Fixed in v9.1.2! 🎉
Thanks to @r3st0r3 for both reporting the issue and submitting the fix via PR #52.
Changes included in v9.1.2:
Wait-PveTaskIsFinish: replaced the busy-wait loop withStart-Sleepto eliminate 100% CPU usageWait-PveTaskIsFinish: fixed timeout calculation usingTotalMillisecondsinstead ofMillisecondsWait-PveTaskIsFinishedWithProgress: same fix plus a PowerShell progress bar while waitingYou can update with: