A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-October/057147.html below:

[Python-Dev] Pythonic concurrency

[Python-Dev] Pythonic concurrencyMichael Sparks Michaels at rd.bbc.co.uk
Mon Oct 10 15:58:25 CEST 2005
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
Michael.Sparks at rd.bbc.co.uk, 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.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4