Package gofer :: Package rmi :: Module async :: Class WatchDog
[hide private]
[frames] | no frames]

Class WatchDog

source code

object --+
         |
        WatchDog

A watchdog object used to track asynchronous messages by serial number. Tracking is persisted using journal files.

Nested Classes [hide private]
  __metaclass__
Singleton metaclass usage: __metaclass__ = Singleton
Instance Methods [hide private]
 
__init__(self, url='tcp://localhost:5672', journal=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
WatchDogThread
start(self)
Start a watchdog thread.
source code
 
track(self, sn, replyto, any, timeout)
Add a request by serial number for tacking.
source code
 
started(self, sn)
Timeout is a tuple of: (start,complete).
source code
 
progress(self, sn)
Progress reporting received.
source code
 
completed(self, sn)
The request has been properly completed by the agent.
source code
 
process(self)
Process all outstanding journal entries.
source code
 
__overdue(self, je)
Send the (timeout) reply to the replyto AMQP address specified in the journal entry.
source code
 
__sendreply(self, je)
Send the (timeout) reply to the replyto AMQP address specified in the journal entry.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  URL = 'tcp://localhost:5672'
Instance Variables [hide private]
Journal __jnl
A journal use for persistence.
Producer __producer
An AMQP message producer.
bool __run
Run flag.
str url
The AMQP broker URL.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, url='tcp://localhost:5672', journal=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • url (str) - The (optional) broker URL.
  • journal (Journal) - A journal object (default: Journal()).
Overrides: object.__init__

start(self)

source code 

Start a watchdog thread.

Returns: WatchDogThread
The started thread.

track(self, sn, replyto, any, timeout)

source code 

Add a request by serial number for tacking.

Parameters:
  • sn (str) - A serial number.
  • replyto (str) - An AMQP address.
  • any (any) - User defined data.
  • timeout (tuple(2)) - A timeout (start,complete)

started(self, sn)

source code 

Timeout is a tuple of: (start,complete). A proper status='started' has been received and the timout index is changed from 0 to 1. This switches the timeout logic to work off the 2nd timeout which indicates the completion timeout.

Parameters:
  • sn (str) - An entry serial number.

progress(self, sn)

source code 

Progress reporting received. Because a progress report has been received, the current timestamp is bumped 5 seconds only if the timestamp is within 5 seconds of expiration.

completed(self, sn)

source code 

The request has been properly completed by the agent. Tracking is discontinued.

Parameters:
  • sn (str) - An entry serial number.

process(self)

source code 

Process all outstanding journal entries. When a journal entry (timeout) is detected, a RequestTimeout exception is raised and sent to the replyto AMQP address. The journal entry is deleted.

__overdue(self, je)

source code 

Send the (timeout) reply to the replyto AMQP address specified in the journal entry.

Parameters:
  • je (Entry) - A journal entry.

__sendreply(self, je)

source code 

Send the (timeout) reply to the replyto AMQP address specified in the journal entry.

Parameters:
  • je (Entry) - A journal entry.