Hi Steve,

On Saturday 04 April 2009 23:30:14 Steve wrote:
> I look forward to any thoughts or comments you might have on these
> components.

For various (personal) reasons I won't be able to review this until Friday
this week. Generally they look good though and would be welcome additions.
There are a variety of changes and improvements I'd make, some which are
stylistic, but some others would improve reuse.

As an example of what I mean, I'd probably change SingleTick to be more like
this:

class SingleTick(Axon.ThreadedComponent.threadedcomponent):
    '''
    This threaded component will wait "delay" seconds then send True out it's
    outbox and shutdown.  You can specify an optional "check_interval" which
    will cause the component to periodically check it's control inbox for
    early termination signals.
    '''
    Inboxes = {
         "inbox": "Ignored",
         "control": "Sending a message here will cause the component to 
terminate",
    }
    Outboxes = {
         "outbox" : "If the delay is reached uninterrupted the tickmessage - 
default 'True' is sent here",
         "signal" : "producerFinished() if not interrrupted, otherwise the 
interruption/termination message",
    }
    tickmessage = True
    delay = 1
    check_interval = None
    def __init__(self, **argd):
        super(SingleTick, self).__init__(**argd)
        if self.check_interval is None or self.check_interval > self.delay:
            self.check_interval = self.delay

    def main(self):
        delay_until = time.time() + self.delay
        self.pause(self.check_interval)
        now = time.time()
        while not self.dataReady('control') now < delay_until:
            remainder = delay_until - now
            if remainder < self.check_interval and remainder > 0:
                self.pause(remainder)
            else:
                self.pause(self.check_interval)
            now = time.time()

        if self.dataReady('control'):
                self.send(self.recv('control'), 'signal')
        else:
            self.send(self.tickmessage, 'outbox')
            self.send(producerFinished(self), 'signal')

The differences here include:
   * More meta data around use of inboxes & outboxes. (Enabling the doc
      generator to extract this)
      - eg http://www.kamaelia.org/Components/pydoc/Kamaelia.File.Append.Append

   * Use of class attributes to provide default values, and enabling the
      **argd code to override the default values.
         - cf http://www.kamaelia.org/InheritableDefaultValues

   * Logic change in loop to make the code paths clearer.

Regards,


Michael.
-- 
http://yeoldeclue.com/blog
http://twitter.com/kamaelian
http://www.kamaelia.org/Home

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"kamaelia" group.
To post to this group, send email to kamaelia@googlegroups.com
To unsubscribe from this group, send email to 
kamaelia+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to