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
Boris Kocherov
erp5
Commits
19e6cc3e
Commit
19e6cc3e
authored
Jun 08, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of global_activity_buffer_lock.
parent
7daaf0a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
17 deletions
+3
-17
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+3
-17
No files found.
product/CMFActivity/ActivityTool.py
View file @
19e6cc3e
...
@@ -32,6 +32,7 @@ import threading
...
@@ -32,6 +32,7 @@ import threading
import
sys
import
sys
from
types
import
StringType
from
types
import
StringType
import
re
import
re
from
collections
import
defaultdict
from
cPickle
import
dumps
,
loads
from
cPickle
import
dumps
,
loads
from
Products.CMFCore
import
permissions
as
CMFCorePermissions
from
Products.CMFCore
import
permissions
as
CMFCorePermissions
from
Products.ERP5Type.Core.Folder
import
Folder
from
Products.ERP5Type.Core.Folder
import
Folder
...
@@ -140,9 +141,8 @@ def activity_timing_method(method, args, kw):
...
@@ -140,9 +141,8 @@ def activity_timing_method(method, args, kw):
# Here go ActivityBuffer instances
# Here go ActivityBuffer instances
# Structure:
# Structure:
# global_activity_buffer[activity_tool_path][thread_id] = ActivityBuffer
# global_activity_buffer[activity_tool_path][thread_id] = ActivityBuffer
global_activity_buffer
=
{}
global_activity_buffer
=
defaultdict
(
dict
)
from
thread
import
get_ident
,
allocate_lock
from
thread
import
get_ident
global_activity_buffer_lock
=
allocate_lock
()
def
registerActivity
(
activity
):
def
registerActivity
(
activity
):
# Must be rewritten to register
# Must be rewritten to register
...
@@ -1032,26 +1032,12 @@ class ActivityTool (Folder, UniqueObject):
...
@@ -1032,26 +1032,12 @@ class ActivityTool (Folder, UniqueObject):
is True, create one.
is True, create one.
Intermediate level is unconditionaly created if non existant because
Intermediate level is unconditionaly created if non existant because
chances are it will be used in the instance life.
chances are it will be used in the instance life.
Lock is held when checking for intermediate level existance
because:
- intermediate level dict must not be created in 2 threads at the
same time, since one creation would destroy the existing one.
It's released after that step because:
- lower level access is at thread scope, thus by definition there
can be only one access at a time to a key
- GIL protects us when accessing python instances
"""
"""
# Safeguard: make sure we are wrapped in acquisition context before
# Safeguard: make sure we are wrapped in acquisition context before
# using our path as an activity tool instance-wide identifier.
# using our path as an activity tool instance-wide identifier.
assert
getattr
(
self
,
'aq_self'
,
None
)
is
not
None
assert
getattr
(
self
,
'aq_self'
,
None
)
is
not
None
my_instance_key
=
self
.
getPhysicalPath
()
my_instance_key
=
self
.
getPhysicalPath
()
my_thread_key
=
get_ident
()
my_thread_key
=
get_ident
()
global_activity_buffer_lock
.
acquire
()
try
:
if
my_instance_key
not
in
global_activity_buffer
:
global_activity_buffer
[
my_instance_key
]
=
{}
finally
:
global_activity_buffer_lock
.
release
()
thread_activity_buffer
=
global_activity_buffer
[
my_instance_key
]
thread_activity_buffer
=
global_activity_buffer
[
my_instance_key
]
try
:
try
:
return
thread_activity_buffer
[
my_thread_key
]
return
thread_activity_buffer
[
my_thread_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