Package ZenHub :: Package services :: Module Beat
[hide private]
[frames] | no frames]

Source Code for Module ZenHub.services.Beat

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13   
14  from HubService import HubService 
15  from twisted.internet import reactor 
16  from twisted.spread import pb 
17  import time 
18   
19 -class Beat(HubService):
20 """Example service which sends a simple heartbeat to keep a client 21 connection alive.""" 22
23 - def __init__(self, dmd, instance):
24 HubService.__init__(self, dmd, instance) 25 self.beat()
26
27 - def beat(self):
28 secs = time.time() 29 for listener in self.listeners: 30 d = listener.callRemote('beat', secs) 31 d.addErrback(self.error) 32 reactor.callLater(1, self.beat)
33
34 - def error(self, reason, listener):
35 reason.printTraceback()
36