Commit b78f4b96 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Fixed use of locks : checking number of running threads and incrementing the

  variable must be dont within the same lock.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5667 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 363034bc
......@@ -470,24 +470,20 @@ class ActivityTool (Folder, UniqueObject):
global active_threads, is_initialized
# return if the number of threads is too high
# else, increase the number of active_threads and continue
tic_lock.acquire()
too_many_threads = (active_threads >= max_active_threads)
if not too_many_threads:
active_threads += 1
tic_lock.release()
if too_many_threads :
if not force:
raise RuntimeError, 'Too many threads'
if tic_lock is None:
return
# Initialize if needed
if not is_initialized: self.initialize()
# increase the number of active_threads
tic_lock.acquire()
active_threads += 1
tic_lock.release()
try:
# Wakeup each queue
for activity in activity_list:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment