Commit 984eddfd by Vincent Pelletier

Acquire tick lock in non-blocking mode, similarly to CMFActivity/ActivityTool.py…

…: this allows a process_timer call to return quickly when previous tick is still processing. This prevents portal_alarms from using threads to just wait for one tic call to complete.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23709 20353a03-c40f-0410-a6d1-a30d3c3de9de
1 parent 684cfb56
......@@ -200,21 +200,23 @@ class AlarmTool(BaseTool):
This method is called by TimerService in the interval given
in zope.conf. The Default is every 5 seconds.
"""
# only start when we are the alarmNode
alarmNode = self.getAlarmNode()
current_node = self.getCurrentNode()
if alarmNode == '':
self.setAlarmNode(current_node)
alarmNode = current_node
if alarmNode == current_node:
global last_tic
last_tic_lock.acquire(1)
try:
acquired = last_tic_lock.acquire(0)
if not acquired:
return
try:
# only start when we are the alarmNode
alarmNode = self.getAlarmNode()
current_node = self.getCurrentNode()
if alarmNode == '':
self.setAlarmNode(current_node)
alarmNode = current_node
if alarmNode == current_node:
global last_tic
if tick.timeTime() - last_tic >= self.interval:
self.tic()
last_tic = tick.timeTime()
finally:
last_tic_lock.release()
finally:
last_tic_lock.release()
def getCurrentNode(self):
""" Return current node in form ip:port """
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!