Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
feb87a8a
Commit
feb87a8a
authored
Jun 14, 2018
by
christopher lee
Committed by
Christopher Lee
Jun 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add wait time to courses api for refresh_course_metadata
LEARNER-5560
parent
ede1cb24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
course_discovery/apps/core/views.py
+2
-0
course_discovery/apps/course_metadata/data_loaders/api.py
+13
-0
No files found.
course_discovery/apps/core/views.py
View file @
feb87a8a
...
...
@@ -8,7 +8,9 @@ from django.db import DatabaseError, connection, transaction
from
django.http
import
Http404
,
JsonResponse
from
django.shortcuts
import
redirect
from
django.views.generic
import
View
from
course_discovery.apps.core.constants
import
Status
try
:
import
newrelic.agent
except
ImportError
:
# pragma: no cover
...
...
course_discovery/apps/course_metadata/data_loaders/api.py
View file @
feb87a8a
import
concurrent.futures
import
logging
import
math
import
time
from
decimal
import
Decimal
from
io
import
BytesIO
...
...
@@ -84,9 +85,21 @@ class CoursesApiDataLoader(AbstractDataLoader):
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
self
.
max_workers
)
as
executor
:
# pragma: no cover
if
self
.
is_threadsafe
:
for
page
in
pagerange
:
# This time.sleep is to make it very likely that this method does not encounter a 429 status
# code by increasing the amount of time between each code. More details at LEARNER-5560
# The current crude estimation is for ~3000 courses with a PAGE_SIZE=50 which means this method
# will take ~30 minutes.
# TODO Ticket to gracefully handle 429 https://openedx.atlassian.net/browse/LEARNER-5565
time
.
sleep
(
30
)
executor
.
submit
(
self
.
_load_data
,
page
)
else
:
for
future
in
[
executor
.
submit
(
self
.
_make_request
,
page
)
for
page
in
pagerange
]:
# This time.sleep is to make it very likely that this method does not encounter a 429 status
# code by increasing the amount of time between each code. More details at LEARNER-5560
# The current crude estimation is for ~3000 courses with a PAGE_SIZE=50 which means this method
# will take ~30 minutes.
# TODO Ticket to gracefully handle 429 https://openedx.atlassian.net/browse/LEARNER-5565
time
.
sleep
(
30
)
response
=
future
.
result
()
self
.
_process_response
(
response
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment