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

# Source Code for Module Products.ZenHub.services.Beat

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  from HubService import HubService
    12  from twisted.internet import reactor
    13  import time
    14
    15 -class Beat(HubService):
    16      """Example service which sends a simple heartbeat to keep a client
    17      connection alive."""
    18
    19 -    def __init__(self, dmd, instance):
    20          HubService.__init__(self, dmd, instance)
    21          self.beat()
    22
    23 -    def beat(self):
    24          secs = time.time()
    25          for listener in self.listeners:
    26              d = listener.callRemote('beat', secs)
    27              d.addErrback(self.error)
    28          reactor.callLater(1, self.beat)
    29
    30 -    def error(self, reason, unused):
    31          reason.printTraceback()
    32