Skip to content

Commit

Permalink
Add a bit of randomness to the wait time after source update failure (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcPMS committed Sep 27, 2023
1 parent f600c3b commit bfeaf2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AppInstallerRepositoryCore/RepositorySource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ namespace AppInstaller::Repository
CATCH_LOG();

AICLI_LOG(Repo, Info, << "Source add/update failed, waiting a bit and retrying: " << details.Name);
std::this_thread::sleep_for(2s);

// Add a bit of randomness to the retry wait time
std::default_random_engine randomEngine(std::random_device{}());
std::uniform_int_distribution<long long> distribution(2000, 10000);

std::this_thread::sleep_for(std::chrono::milliseconds(distribution(randomEngine)));

// If this one fails, maybe the problem is persistent.
result = (factory.get()->*member)(details, progress);
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerRepositoryCore/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <map>
#include <memory>
#include <optional>
#include <random>
#include <set>
#include <string>
#include <string_view>
Expand Down

0 comments on commit bfeaf2c

Please sign in to comment.