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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Frederic Thoma
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):
self
.
_namespace_prefix
=
namespace
+
'.'
self
.
_portal_type
=
portal_type
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
sys
.
modules
[
namespace
]
=
self
...
...
@@ -109,17 +110,18 @@ class ComponentDynamicPackage(ModuleType):
# 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
# reindexed
for
component
in
component_tool
.
objectValues
(
portal_type
=
self
.
_portal_type
):
# Only consider modified or validated states as state transition will
# be handled by component_validation_workflow which will take care of
# updating the registry
if
component
.
getValidationState
()
in
(
'modified'
,
'validated'
):
version
=
component
.
getVersion
(
validated_only
=
True
)
# The versions should have always been set on ERP5Site property
# beforehand
if
version
in
version_priority_set
:
reference
=
component
.
getReference
(
validated_only
=
True
)
self
.
__registry_dict
.
setdefault
(
reference
,
{})[
version
]
=
component
with
self
.
_registry_generate_lock
:
for
component
in
component_tool
.
objectValues
(
portal_type
=
self
.
_portal_type
):
# Only consider modified or validated states as state transition will
# be handled by component_validation_workflow which will take care of
# updating the registry
if
component
.
getValidationState
()
in
(
'modified'
,
'validated'
):
version
=
component
.
getVersion
(
validated_only
=
True
)
# The versions should have always been set on ERP5Site property
# beforehand
if
version
in
version_priority_set
:
reference
=
component
.
getReference
(
validated_only
=
True
)
self
.
__registry_dict
.
setdefault
(
reference
,
{})[
version
]
=
component
return
self
.
__registry_dict
...
...
@@ -218,7 +220,7 @@ class ComponentDynamicPackage(ModuleType):
except
AttributeError
:
pass
else
:
with
self
.
_lock
:
with
self
.
_lo
ad_module_lo
ck
:
setattr
(
self
.
_getVersionPackage
(
version
),
component_name
,
module
)
return
module
...
...
@@ -228,7 +230,7 @@ class ComponentDynamicPackage(ModuleType):
component_id
=
'%s.%s_version.%s'
%
(
self
.
_namespace
,
version
,
component_name
)
with
self
.
_lock
:
with
self
.
_lo
ad_module_lo
ck
:
new_module
=
ModuleType
(
component_id
,
component
.
getDescription
())
# 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