diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py
index 74f186b689..f78a1160de 100644
--- a/lms/djangoapps/instructor/views.py
+++ b/lms/djangoapps/instructor/views.py
@@ -225,6 +225,7 @@ def instructor_dashboard(request, course_id):
'problems': problems, # psychometrics
'plots': plots, # psychometrics
'course_errors': modulestore().get_item_errors(course.location),
+ 'djangopid' : os.getpid(),
}
return render_to_response('courseware/instructor_dashboard.html', context)
diff --git a/lms/djangoapps/lms_migration/migrate.py b/lms/djangoapps/lms_migration/migrate.py
index a3a1c595be..403063f983 100644
--- a/lms/djangoapps/lms_migration/migrate.py
+++ b/lms/djangoapps/lms_migration/migrate.py
@@ -35,7 +35,17 @@ def getip(request):
ip = request.META.get('REMOTE_ADDR','None')
return ip
-def manage_modulestores(request,reload_dir=None):
+
+def get_commit_id(course):
+ return course.metadata.get('GIT_COMMIT_ID','No commit id')
+ # getattr(def_ms.courses[reload_dir], 'GIT_COMMIT_ID','No commit id')
+
+
+def set_commit_id(course,commit_id):
+ course.metadata['GIT_COMMIT_ID'] = commit_id
+ # setattr(def_ms.courses[reload_dir], 'GIT_COMMIT_ID', new_commit_id)
+
+def manage_modulestores(request, reload_dir=None, commit_id=None):
'''
Manage the static in-memory modulestores.
@@ -52,8 +62,9 @@ def manage_modulestores(request,reload_dir=None):
ip = getip(request)
if LOCAL_DEBUG:
- html += '
IP address: %s ' % ip
- html += 'User: %s ' % request.user
+ html += 'IP address: %s ' % ip
+ html += 'User: %s
' % request.user
+ html += 'My pid: %s
' % os.getpid()
log.debug('request from ip=%s, user=%s' % (ip,request.user))
if not (ip in ALLOWED_IPS or 'any' in ALLOWED_IPS):
@@ -66,14 +77,27 @@ def manage_modulestores(request,reload_dir=None):
return HttpResponse(html, status=403)
#----------------------------------------
- # reload course if specified
+ # reload course if specified; handle optional commit_id
if reload_dir is not None:
if reload_dir not in def_ms.courses:
html += 'Error: "%s" is not a valid course directory
' % reload_dir
else:
- html += 'Reloaded course directory "%s"
' % reload_dir
- def_ms.try_load_course(reload_dir)
+ # reloading based on commit_id is needed when running mutiple worker threads,
+ # so that a given thread doesn't reload the same commit multiple times
+ current_commit_id = get_commit_id(def_ms.courses[reload_dir])
+ log.debug('commit_id="%s"' % commit_id)
+ log.debug('current_commit_id="%s"' % current_commit_id)
+
+ if (commit_id is not None) and (commit_id==current_commit_id):
+ html += "Already at commit id %s for %s
" % (commit_id, reload_dir)
+ else:
+ html += 'Reloaded course directory "%s"
' % reload_dir
+ def_ms.try_load_course(reload_dir)
+ gdir = settings.DATA_DIR / reload_dir
+ new_commit_id = os.popen('cd %s; git log -n 1 | head -1' % gdir).read().strip().split(' ')[1]
+ set_commit_id(def_ms.courses[reload_dir], new_commit_id)
+ html += '
commit_id=%s
' % new_commit_id
#----------------------------------------
@@ -94,6 +118,8 @@ def manage_modulestores(request,reload_dir=None):
html += '
'
html += 'Course: %s (%s)
' % (course.display_name,cdir)
+ html += 'commit_id=%s
' % get_commit_id(course)
+
for field in dumpfields:
data = getattr(course,field)
html += '%s
' % field
diff --git a/lms/templates/courseware/instructor_dashboard.html b/lms/templates/courseware/instructor_dashboard.html
index d73eda1ed7..e822f05f92 100644
--- a/lms/templates/courseware/instructor_dashboard.html
+++ b/lms/templates/courseware/instructor_dashboard.html
@@ -59,6 +59,8 @@ function goto( mode)
Admin ]
+ ${djangopid}
+