Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
erp5
Commits
2950c0e0
Commit
2950c0e0
authored
Mar 02, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make registry generation of Component package thread-safe.
parent
c00fc402
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+16
-14
No files found.
product/ERP5Type/dynamic/component_package.py
View file @
2950c0e0
...
@@ -73,7 +73,8 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -73,7 +73,8 @@ class ComponentDynamicPackage(ModuleType):
self
.
_namespace_prefix
=
namespace
+
'.'
self
.
_namespace_prefix
=
namespace
+
'.'
self
.
_portal_type
=
portal_type
self
.
_portal_type
=
portal_type
self
.
__version_suffix_len
=
len
(
'_version'
)
self
.
__version_suffix_len
=
len
(
'_version'
)
self
.
_lock
=
threading
.
RLock
()
self
.
_load_module_lock
=
threading
.
RLock
()
self
.
_registry_generate_lock
=
threading
.
RLock
()
# Add this module to sys.path for future imports
# Add this module to sys.path for future imports
sys
.
modules
[
namespace
]
=
self
sys
.
modules
[
namespace
]
=
self
...
@@ -109,17 +110,18 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -109,17 +110,18 @@ class ComponentDynamicPackage(ModuleType):
# this is only done at startup or upon reset, moreover using the Catalog
# this is only done at startup or upon reset, moreover using the Catalog
# is too risky as it lags behind and depends upon objects being
# is too risky as it lags behind and depends upon objects being
# reindexed
# reindexed
for
component
in
component_tool
.
objectValues
(
portal_type
=
self
.
_portal_type
):
with
self
.
_registry_generate_lock
:
# Only consider modified or validated states as state transition will
for
component
in
component_tool
.
objectValues
(
portal_type
=
self
.
_portal_type
):
# be handled by component_validation_workflow which will take care of
# Only consider modified or validated states as state transition will
# updating the registry
# be handled by component_validation_workflow which will take care of
if
component
.
getValidationState
()
in
(
'modified'
,
'validated'
):
# updating the registry
version
=
component
.
getVersion
(
validated_only
=
True
)
if
component
.
getValidationState
()
in
(
'modified'
,
'validated'
):
# The versions should have always been set on ERP5Site property
version
=
component
.
getVersion
(
validated_only
=
True
)
# beforehand
# The versions should have always been set on ERP5Site property
if
version
in
version_priority_set
:
# beforehand
reference
=
component
.
getReference
(
validated_only
=
True
)
if
version
in
version_priority_set
:
self
.
__registry_dict
.
setdefault
(
reference
,
{})[
version
]
=
component
reference
=
component
.
getReference
(
validated_only
=
True
)
self
.
__registry_dict
.
setdefault
(
reference
,
{})[
version
]
=
component
return
self
.
__registry_dict
return
self
.
__registry_dict
...
@@ -218,7 +220,7 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -218,7 +220,7 @@ class ComponentDynamicPackage(ModuleType):
except
AttributeError
:
except
AttributeError
:
pass
pass
else
:
else
:
with
self
.
_lock
:
with
self
.
_lo
ad_module_lo
ck
:
setattr
(
self
.
_getVersionPackage
(
version
),
component_name
,
module
)
setattr
(
self
.
_getVersionPackage
(
version
),
component_name
,
module
)
return
module
return
module
...
@@ -228,7 +230,7 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -228,7 +230,7 @@ class ComponentDynamicPackage(ModuleType):
component_id
=
'%s.%s_version.%s'
%
(
self
.
_namespace
,
version
,
component_id
=
'%s.%s_version.%s'
%
(
self
.
_namespace
,
version
,
component_name
)
component_name
)
with
self
.
_lock
:
with
self
.
_lo
ad_module_lo
ck
:
new_module
=
ModuleType
(
component_id
,
component
.
getDescription
())
new_module
=
ModuleType
(
component_id
,
component
.
getDescription
())
# The module *must* be in sys.modules before executing the code in case
# The module *must* be in sys.modules before executing the code in case
...
...
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