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

# Source Code for Module Products.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  import time
    17
    18 -class Beat(HubService):
    19      """Example service which sends a simple heartbeat to keep a client
    20      connection alive."""
    21
    22 -    def __init__(self, dmd, instance):
    23          HubService.__init__(self, dmd, instance)
    24          self.beat()
    25
    26 -    def beat(self):
    27          secs = time.time()
    28          for listener in self.listeners:
    29              d = listener.callRemote('beat', secs)
    30              d.addErrback(self.error)
    31          reactor.callLater(1, self.beat)
    32
    33 -    def error(self, reason, unused):
    34          reason.printTraceback()
    35