Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
f731d5fe
Commit
f731d5fe
authored
Jul 31, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify thread-safety of bulk_write context manager
parent
d2ffca2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
common/lib/xmodule/xmodule/modulestore/__init__.py
+1
-1
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+12
-3
No files found.
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
f731d5fe
...
...
@@ -646,7 +646,7 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite):
@contextmanager
def
bulk_write_operations
(
self
,
course_id
):
"""
A context manager for notifying the store of bulk write events.
A context manager for notifying the store of bulk write events.
This affects only the current thread.
In the case of Mongo, it temporarily disables refreshing the metadata inheritance tree
until the bulk operation is completed.
...
...
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
f731d5fe
...
...
@@ -414,7 +414,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
# performance optimization to prevent updating the meta-data inheritance tree during
# bulk write operations
self
.
ignore_write_events_on_courses
=
set
()
self
.
ignore_write_events_on_courses
=
threading
.
local
()
self
.
_course_run_cache
=
{}
def
close_connections
(
self
):
...
...
@@ -439,13 +439,19 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
"""
Prevent updating the meta-data inheritance cache for the given course
"""
self
.
ignore_write_events_on_courses
.
add
(
course_id
)
if
not
hasattr
(
self
.
ignore_write_events_on_courses
.
courses
):
self
.
ignore_write_events_on_courses
.
courses
=
set
()
self
.
ignore_write_events_on_courses
.
courses
.
add
(
course_id
)
def
_end_bulk_write_operation
(
self
,
course_id
):
"""
Restart updating the meta-data inheritance cache for the given course.
Refresh the meta-data inheritance cache now since it was temporarily disabled.
"""
if
not
hasattr
(
self
.
ignore_write_events_on_courses
.
courses
):
return
if
course_id
in
self
.
ignore_write_events_on_courses
:
self
.
ignore_write_events_on_courses
.
remove
(
course_id
)
self
.
refresh_cached_metadata_inheritance_tree
(
course_id
)
...
...
@@ -454,8 +460,11 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
"""
Returns whether a bulk write operation is in progress for the given course.
"""
if
not
hasattr
(
self
.
ignore_write_events_on_courses
.
courses
):
return
False
course_id
=
course_id
.
for_branch
(
None
)
return
course_id
in
self
.
ignore_write_events_on_courses
return
course_id
in
self
.
ignore_write_events_on_courses
.
courses
def
fill_in_run
(
self
,
course_key
):
"""
...
...
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