multipass
multipass copied to clipboard
Retry on download failure
fix #3464
This PR adds binary exponential backoff based retry mechanism to async periodic download tasks, the checking exception (download failure an exception) in the main thread is done in a non-blocking fashion via QFutureWatcher
.
- Changed
std::async
+std::future
pair toQtConcurrent::run
+QFuture
in order to use some QFuture specific features. - Added
QFutureWatcher
to watchQFuture
and react correspondingly in the successful and failed cases when QFuture is finished. - Changed
DownloadException
to a QException-based class so it can cross the qt thread boundary. - Made the CRTP
BaseQException
class to reuse the boilerplate code for all the QException derived classes.
To test the behavior, you can modify the default delay time in daemon.h
line 222 to a small number, so the download will run more frequently. After that, the wifi network can be manually turned off in ubuntu settings, which in a way causes download failure.
Codecov Report
Attention: Patch coverage is 85.00000%
with 6 lines
in your changes are missing coverage. Please review.
Project coverage is 88.83%. Comparing base (
2a16af2
) to head (42d1612
).
Files | Patch % | Lines |
---|---|---|
include/multipass/async_periodic_download_task.h | 85.18% | 4 Missing :warning: |
include/multipass/exceptions/base_qexception.h | 71.42% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #3487 +/- ##
==========================================
+ Coverage 88.82% 88.83% +0.01%
==========================================
Files 254 253 -1
Lines 14115 14119 +4
==========================================
+ Hits 12537 12542 +5
+ Misses 1578 1577 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hey @georgeliao, thanks for the work on this!
Would you be able to edit the PR description to link the github issues that this fixes in the format 'Fixes #xxxx'? That way I can get some more context on what behavior this is fixing.
Thanks!
@sharder996 , sorry that I forgot it, the link is added now. I also added more text in the intro to explain the context. Be free to ask any questions if something is not clear.