[Erp5-report] r23709 - /erp5/trunk/products/ERP5/Tool/AlarmTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Sep 19 04:59:20 CEST 2008
Author: vincent
Date: Fri Sep 19 04:59:19 2008
New Revision: 23709
URL: http://svn.erp5.org?rev=23709&view=rev
Log:
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.
Modified:
erp5/trunk/products/ERP5/Tool/AlarmTool.py
Modified: erp5/trunk/products/ERP5/Tool/AlarmTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/AlarmTool.py?rev=23709&r1=23708&r2=23709&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/AlarmTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/AlarmTool.py Fri Sep 19 04:59:19 2008
@@ -200,21 +200,23 @@
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 """
More information about the Erp5-report
mailing list