Commit 984eddfd authored by Vincent Pelletier's avatar Vincent Pelletier

Acquire tick lock in non-blocking mode, similarly to...

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
parent 684cfb56
...@@ -200,6 +200,10 @@ class AlarmTool(BaseTool): ...@@ -200,6 +200,10 @@ class AlarmTool(BaseTool):
This method is called by TimerService in the interval given This method is called by TimerService in the interval given
in zope.conf. The Default is every 5 seconds. in zope.conf. The Default is every 5 seconds.
""" """
acquired = last_tic_lock.acquire(0)
if not acquired:
return
try:
# only start when we are the alarmNode # only start when we are the alarmNode
alarmNode = self.getAlarmNode() alarmNode = self.getAlarmNode()
current_node = self.getCurrentNode() current_node = self.getCurrentNode()
...@@ -208,8 +212,6 @@ class AlarmTool(BaseTool): ...@@ -208,8 +212,6 @@ class AlarmTool(BaseTool):
alarmNode = current_node alarmNode = current_node
if alarmNode == current_node: if alarmNode == current_node:
global last_tic global last_tic
last_tic_lock.acquire(1)
try:
if tick.timeTime() - last_tic >= self.interval: if tick.timeTime() - last_tic >= self.interval:
self.tic() self.tic()
last_tic = tick.timeTime() last_tic = tick.timeTime()
......
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