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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Lu Xu
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
Show 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,6 +110,7 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -109,6 +110,7 @@ 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
with
self
.
_registry_generate_lock
:
for
component
in
component_tool
.
objectValues
(
portal_type
=
self
.
_portal_type
):
for
component
in
component_tool
.
objectValues
(
portal_type
=
self
.
_portal_type
):
# Only consider modified or validated states as state transition will
# Only consider modified or validated states as state transition will
# be handled by component_validation_workflow which will take care of
# be handled by component_validation_workflow which will take care of
...
@@ -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