Skip to content

Commit

Permalink
Add retry logic and error handling to speed test results polling & cl…
Browse files Browse the repository at this point in the history
…eanup #24
  • Loading branch information
mhdzumair authored Nov 15, 2024
2 parents 8584387 + 2bca18a commit ff110e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 70 deletions.
10 changes: 9 additions & 1 deletion mediaflow_proxy/static/speedtest.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ <h3 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Test Summar
}

async function pollResults(taskId) {
let retryCount = 0;
const maxRetries = 10;
try {
while (true) {
const response = await fetch(`/speedtest/results/${taskId}`, {
Expand All @@ -411,10 +413,16 @@ <h3 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Test Summar
handleAuthError();
return;
}
throw new Error('Failed to fetch results');
if (retryCount < maxRetries) {
retryCount++
await new Promise(resolve => setTimeout(resolve, 2000));
continue;
}
throw new Error('Failed to fetch results after multiple attempts');
}

const data = await response.json();
retryCount = 0; //reset the retry count

if (data.status === 'failed') {
throw new Error('Speed test failed');
Expand Down
69 changes: 0 additions & 69 deletions mediaflow_proxy/utils/rd_speedtest.py

This file was deleted.

0 comments on commit ff110e1

Please sign in to comment.