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
Léo-Paul Géneau
erp5
Commits
220e0c37
Commit
220e0c37
authored
Feb 26, 2018
by
Hardik Juneja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFActivity: Use roundrobin for dequeue the messages
parent
2e52eb56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+8
-8
No files found.
product/CMFActivity/ActivityTool.py
View file @
220e0c37
...
@@ -1085,20 +1085,20 @@ class ActivityTool (Folder, UniqueObject):
...
@@ -1085,20 +1085,20 @@ class ActivityTool (Folder, UniqueObject):
try
:
try
:
# Loop as long as there are activities. Always process the queue with
# Loop as long as there are activities. Always process the queue with
# "highest" priority. If several queues have same highest priority, do
# "highest" priority. If several queues have same highest priority,
# not choose one that has just been processed.
# use a round-robin algorithm.
# This algorithm is fair enough because we only have 2 queues.
# Otherwise, a round-robin of highest-priority queues would be required.
# XXX: We always finish by iterating over all queues, in case that
# XXX: We always finish by iterating over all queues, in case that
# getPriority does not see messages dequeueMessage would process.
# getPriority does not see messages dequeueMessage would process.
last
=
None
activity_list
=
activity_dict
.
values
()
def
sort_key
(
activity
):
def
sort_key
(
activity
):
return
activity
.
getPriority
(
self
)
,
activity
is
last
return
activity
.
getPriority
(
self
)
while
is_running_lock
.
acquire
(
0
):
while
is_running_lock
.
acquire
(
0
):
try
:
try
:
for
last
in
sorted
(
activity_dict
.
values
(),
key
=
sort_key
):
activity_list
.
sort
(
key
=
sort_key
)
# stable sort
for
i
,
activity
in
enumerate
(
activity_list
):
# Transaction processing is the responsability of the activity
# Transaction processing is the responsability of the activity
if
not
last
.
dequeueMessage
(
inner_self
,
processing_node
):
if
not
activity
.
dequeueMessage
(
inner_self
,
processing_node
):
activity_list
.
append
(
activity_list
.
pop
(
i
))
break
break
else
:
else
:
break
break
...
...
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