On Thu, 2010-01-21 at 08:54 -0800, Steve Howell wrote: > Hi, I'm looking for ideas on building a simple architecture that > allows a bunch of independent Python processes to exchange data using > files and perform calculations. > One Python program would be collecting data from boat instruments on a > serial port, then writing that info out to a file, and also > transmitting data to instruments as needed (again through the serial > port). It would be the most complex program in terms of having to > poll file descriptors, or something similar, but I want to limit its > job to pure communication handling.
This should be pretty easy using multiprocessing. In OpenGroupware Coils we have a master process <http://coils.hg.sourceforge.net/hgweb/coils/coils/file/2c7847ef0527/src/coils-master-service.py> that spins up children (workers, that each provide a distinct service) it opens a Pipe to each child to send messages to the child and a Queue from which it reads [all children (clients) write to the Queue and listen on their Pipe]. Then the master just listens on its pipe and forwards messages from children to other children. All children are Service objects <http://coils.hg.sourceforge.net/hgweb/coils/coils/file/2c7847ef0527/src/coils/core/service.py>. Then implementing a new service [type of worker] is as easy as (our brutally simple pubsub service) <http://coils.hg.sourceforge.net/hgweb/coils/coils/file/2c7847ef0527/src/coils/logic/pubsub/service.py> Hope that helps. -- OpenGroupware developer: awill...@whitemice.org <http://whitemiceconsulting.blogspot.com/> OpenGroupare & Cyrus IMAPd documenation @ <http://docs.opengroupware.org/Members/whitemice/wmogag/file_view> -- http://mail.python.org/mailman/listinfo/python-list