fix: adjust exponential backoff timing in scrape_jobs_with_retry
This commit is contained in:
@@ -8,14 +8,14 @@ class TestScheduler:
|
|||||||
|
|
||||||
def test_scrape_jobs_with_retry_success(self):
|
def test_scrape_jobs_with_retry_success(self):
|
||||||
"""Test that scrape_jobs_with_retry succeeds on first attempt."""
|
"""Test that scrape_jobs_with_retry succeeds on first attempt."""
|
||||||
with patch('web.craigslist.scrape_jobs') as mock_scrape:
|
with patch('web.craigslist.scraper') as mock_scrape:
|
||||||
result = scrape_jobs_with_retry()
|
result = scrape_jobs_with_retry()
|
||||||
assert result is True
|
assert result is True
|
||||||
mock_scrape.assert_called_once()
|
mock_scrape.assert_called_once()
|
||||||
|
|
||||||
def test_scrape_jobs_with_retry_failure(self):
|
def test_scrape_jobs_with_retry_failure(self):
|
||||||
"""Test that scrape_jobs_with_retry handles failures properly."""
|
"""Test that scrape_jobs_with_retry handles failures properly."""
|
||||||
with patch('web.craigslist.scrape_jobs', side_effect=Exception("Test error")) as mock_scrape:
|
with patch('web.craigslist.scraper', side_effect=Exception("Test error")) as mock_scrape:
|
||||||
result = scrape_jobs_with_retry(max_retries=2)
|
result = scrape_jobs_with_retry(max_retries=2)
|
||||||
assert result is False
|
assert result is False
|
||||||
assert mock_scrape.call_count == 2
|
assert mock_scrape.call_count == 2
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ def scrape_jobs_with_retry(max_retries=3):
|
|||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if attempt < max_retries - 1:
|
if attempt < max_retries - 1:
|
||||||
time.sleep(2 ** attempt * 60) # Exponential backoff
|
time.sleep(2 ** attempt * 10) # Exponential backoff
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user