Transfer data between two separately running python programs.

MDK mdk at mdk.com
Mon Jan 28 11:03:11 EST 2002


I've spent many hours trying to understand and then implement this.  I've
added the code to my collector and my analyzer.  However, when I get to
coll.run() the analyer program still stops execution while the collection
sits in its loop collecting data.  The DataAnalyzer class does get the data
as I can see it by putting sys.stdout.write(somebytes) in the feed fuction.

I just don't see how this was supposed to solve my problem.  Am I missing
something?

Thanks.

"Gillou" <nospam at bigfoot.com> wrote in message
news:a2scas$46p$1 at norfair.nerim.net...
> Unfortunately it seems that Windows python does not support FIFO pipes
> (os.mkfifo) but...
> With this typically OO approach, you can plug into the SerialCollector any
> analyzer object with a "feed" method.
> You don't need a file as intermediate data storage.
> This approach can be inproved using Queue objects (Queue module in the
> standard doc) especially if the data are collected in threads.
>
> === file collector.py ===
> class SerialCollector:
>     def __init__(self, dataconsumer):
>         self.dataconsumer = dataconsumer
>         # Other stuffs
>         return
>
>     def havedata(self, somebytes):
>         self.dataconsumer.feed(somebytes)
>         return
>
>     def run(self):
>         # Start collecting
> === end collector.py ===
>
> === file analyzer.py ===
> class DataAnalyzer:
>     def __init__(self):
>         # whatever U want
>         return
>
>     def feed(self, somebytes):
>         # Do what you want with collected data
>
> from collector import SerialCollector
>
> myda = DataAnalyzer()
> coll = SerialCollector(myda)
> coll.run()
> === end analyzer.py ===
>
> "MDK" <mdk at mdk.com> a écrit dans le message news:
> a2s48e$13t160$1 at ID-98166.news.dfncis.de...
> > Using PythonWin32 extensions I have a python program (collector.py) that
> > just monitors the serial port and collects data by running in a
continuous
> > loop.
> >
> > I want to get at that data from a different python program.
> >
> > I've considered having collector.py write the data to a file every few
> > seconds and then read the file from the other program but that just
> doesn't
> > seem 'clean' enough.
> >
> > I can't import collector and then run the loop because it stops the
> calling
> > program execution.
> >
> > Any ideas on how to resolve this?
> >
> > Thanks
> >
> >
>
>





More information about the Python-list mailing list