On Wednesday 04 March 2009 00:04:13 Matt Hammond wrote:
> The timeout feature is there, to my mind, because it provide a convenient
> way to provide basic timing facilities, very nearly for free (since the
> threading.Event() object it uses to pause has an optional timeout argument
> already built in)
>
> In my understanding, there is therefore no difference between self.pause()
> for generator based components and threaded components, except from the
> fact that the pause-ing will not happen in a generator based component
> until the next yield statement is reached.

This second paragraph disagrees with the first.

In a generator component, writing:
    self.pause(1.0)

Will break. cf:
>>> import Axon
cl>>>
>>>
>>> class T(Axon.Component.component):
...    def main(self):
...        self.pause(1.0)
...        yield 1
...
>>> T().run()
Here 5485
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Axon/Microprocess.py", line 575, in run
    self.__class__.schedulerClass.run.runThreads()
  File "Axon/Scheduler.py", line 546, in runThreads
    for i in self.main(slowmo,canblock=True): pass
  File "Axon/Scheduler.py", line 440, in main
    result = mprocess.next()
  File "Axon/Microprocess.py", line 399, in next
    return self.__thread.next()
  File "Axon/Microprocess.py", line 508, in _microprocessGenerator
    v = pc.next()
  File "<stdin>", line 3, in main
TypeError: pause() takes exactly 1 argument (2 given)

In a threaded component you can write:

   * self.pause(1.0)

And it will result in the component pausing for 1 second unless awoken by 
traffic sooner.

>>> import Axon
>>> class T(Axon.ThreadedComponent.thread
Axon.ThreadedComponent.threadedadaptivecommscomponent  
Axon.ThreadedComponent.threadedcomponent               
Axon.ThreadedComponent.threading
>>> class T(Axon.ThreadedComponent.threadedcomponent):
...     def main(self):
...         self.pause(1.0)
...
>>> T().run()
>>>



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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to