On Monday 10 Oct 2005 15:45, Donovan Baarda wrote:
> Sounds like yet another reason to avoid threading and use processes
> instead... effort spent on threading based message passing
> implementations could instead be spent on inter-process messaging.

I can't let that pass (even if our threaded component has a couple of warts
at the moment).

# Blocking thread example (uses raw_input) to single threaded pygame
# display ticker. (The display is rate limited to 8 words per second at
# most since it was designed for subtitles)
#
from Axon.ThreadedComponent import threadedcomponent
from Kamaelia.Util.PipelineComponent import pipeline
from Kamaelia.UI.Pygame.Ticker import Ticker

class ConsoleReader(threadedcomponent):
   def __init__(self, prompt=">>> "):
      super(ConsoleReader, self).__init__()
      self.prompt = prompt

   def run(self): # implementation wart, should be "main"
      while 1:
         line = raw_input(self.prompt)
         line = line + "\n"
         self.outqueues["outbox"].put(line)  # implementation wart, should be 
self.send(line, "outbox")

pipeline(
          ConsoleReader(),
          Ticker() # Single threaded pygame based text ticker
).run()

There's other ways with other systems to achieve the same goal. 

Inter-process based messaging can be done in various ways. The API though
can look pretty much the same. (There's obviously some implications of
crossing process boundaries though, but that's for the system composer
to deal with, not the components).

Regards,


Michael.
-- 
Michael Sparks, Senior R&D Engineer, Digital Media Group
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This e-mail may contain personal views which are not the views of the BBC.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to