<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Here's an XMLRPC quick start:<div><br><div><span class="Apple-style-span" style="text-decoration: underline;">1. Type this in a new python script called pyserve.py</span></div><div><div><br></div><div>from SimpleXMLRPCServer import SimpleXMLRPCServer</div><div>from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler</div><div><br></div><div># Restrict to a particular path.</div><div>class RequestHandler(SimpleXMLRPCRequestHandler):</div><div>&nbsp;&nbsp; &nbsp;rpc_paths = ('/RPC2',)</div><div><br></div><div># Create server</div><div>server = SimpleXMLRPCServer(("localhost", 8001),</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestHandler=RequestHandler)</div><div>server.register_introspection_functions()</div><div><br></div><div>x_to_y_buffer=[]</div><div>def send_fromxtoy(x):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>global x_to_y_buffer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>x_to_y_buffer.append(x)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return len(x_to_y_buffer)</div><div><br></div><div>server.register_function(send_fromxtoy, 'send_fromxtoy')</div><div><br></div><div>def receive_fromxtoy():</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>global x_to_y_buffer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if len(x_to_y_buffer):</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return True,x_to_y_buffer.pop(0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>else:</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return False,0</div><div><br></div><div>server.register_function(receive_fromxtoy, 'receive_fromxtoy')</div><div><br></div><div># Run the server's main loop</div><div>server.serve_forever()</div><div><br></div></div><div><span class="Apple-style-span" style="text-decoration: underline;">2. Run that script from your machine's command prompt:</span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&gt;&gt;&gt; python pyserve.py</div><div><br></div><div><div><span class="Apple-style-span" style="text-decoration: underline; ">3. Start interactive sessions to test your data exchanger:</span></div><div>From a second command prompt run ipython and type&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In [1]: import xmlrpclib<div>&nbsp;<span class="Apple-tab-span" style="white-space: pre; ">        In [2]: xmlrpclib.ServerProxy('<a href="http://localhost:8001">http://localhost:8001</a>').send_fromxtoy('hello1')</span></div><div><div>&nbsp;<span class="Apple-tab-span" style="white-space: pre; ">        In [</span>3<span class="Apple-tab-span" style="white-space: pre; ">]: xmlrpclib.ServerProxy('<a href="http://localhost:8001">http://localhost:8001</a>').send_fromxtoy('hello</span>2<span class="Apple-tab-span" style="white-space: pre; ">')</span></div></div></div></div><div><br><div>From a third command prompt run ipython and type</div><div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>In [1]: import xmlrpclib</div><div><div><div>&nbsp;<span class="Apple-tab-span" style="white-space: pre; ">        In [2]: </span>xmlrpclib.ServerProxy('<a href="http://localhost:8001">http://localhost:8001</a>').receive_fromxtoy()</div><div><div><div>&nbsp;<span class="Apple-tab-span" style="white-space: pre; ">        In [</span>3<span class="Apple-tab-span" style="white-space: pre; ">]: </span>xmlrpclib.ServerProxy('<a href="http://localhost:8001">http://localhost:8001</a>').receive_fromxtoy()</div><div><div>&nbsp;<span class="Apple-tab-span" style="white-space: pre; ">        In [</span>4<span class="Apple-tab-span" style="white-space: pre; ">]: </span>xmlrpclib.ServerProxy('<a href="http://localhost:8001">http://localhost:8001</a>').receive_fromxtoy()</div><div><br></div></div></div></div></div></div></div><div>(To be clear an xmlrpc 'server' is just another process whose only job is to send and receive stuff. You will put the send/receive calls, of step 3, in the two processes you have already written).</div><div><br></div><div>See also&nbsp;<a href="http://docs.python.org/library/simplexmlrpcserver.html">http://docs.python.org/library/simplexmlrpcserver.html</a></div><div><br></div><div>Riaz</div><div><span class="Apple-style-span" style="text-decoration: underline;"><br></span></div></div><div><div><div>On Jul 10, 2009, at 10:40 AM, <a href="mailto:baypiggies-request@python.org">baypiggies-request@python.org</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Send Baypiggies mailing list submissions to<br><span class="Apple-tab-span" style="white-space:pre">        </span><a href="mailto:baypiggies@python.org">baypiggies@python.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br><span class="Apple-tab-span" style="white-space:pre">        </span>http://mail.python.org/mailman/listinfo/baypiggies<br>or, via email, send a message with subject or body 'help' to<br><span class="Apple-tab-span" style="white-space:pre">        </span>baypiggies-request@python.org<br><br>You can reach the person managing the list at<br><span class="Apple-tab-span" style="white-space:pre">        </span>baypiggies-owner@python.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Baypiggies digest..."<br><br><br>Today's Topics:<br><br> &nbsp;&nbsp;1. Re: &nbsp;Timing: OSCON meeting (Aahz)<br> &nbsp;&nbsp;2. Re: &nbsp;Help ! How to exchange python objects between two<span class="Apple-tab-span" style="white-space:pre">        </span>python<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processes on the same machine ? (Bill Janssen)<br> &nbsp;&nbsp;3. Re: &nbsp;Help ! How to exchange python objects between two<span class="Apple-tab-span" style="white-space:pre">        </span>python<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processes on the same machine ? (Harish Mallipeddi)<br> &nbsp;&nbsp;4. Re: &nbsp;Help ! How to exchange python objects between<span class="Apple-tab-span" style="white-space:pre">        </span>two<span class="Apple-tab-span" style="white-space:pre">        </span>python<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processes on the same machine ? (Aahz)<br> &nbsp;&nbsp;5. Re: &nbsp;Help ! How to exchange python objects between two<span class="Apple-tab-span" style="white-space:pre">        </span>python<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processes on the same machine ? (Harish Mallipeddi)<br> &nbsp;&nbsp;6. Re: &nbsp;Help ! How to exchange python objects between two<span class="Apple-tab-span" style="white-space:pre">        </span>python<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processes on the same machine ? (David Berthelot)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Fri, 10 Jul 2009 09:35:42 -0700<br>From: Aahz &lt;aahz@pythoncraft.com&gt;<br>To: baypiggies@python.org<br>Subject: Re: [Baypiggies] Timing: OSCON meeting<br>Message-ID: &lt;20090710163542.GB16853@panix.com&gt;<br>Content-Type: text/plain; charset=us-ascii<br><br>On Thu, Jul 09, 2009, Aahz wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">Unless someone objects by midnight tonight (Thursday), I'll tell the<br></blockquote><blockquote type="cite">OSCON people to schedule BayPIGgies for 8-9:30pm Thurs 7/23 in the same<br></blockquote><blockquote type="cite">room as Wes's BoF -- that should give us enough time to make<br></blockquote><blockquote type="cite">announcements.<br></blockquote><br>Posted to c.l.py and c.l.py.announce -- would someone please update the<br>website and include a note about Wes's BoF in addition to the meeting<br>itself?<br>-- <br>Aahz (aahz@pythoncraft.com) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;*&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.pythoncraft.com/<br><br>"as long as we like the same operating system, things are cool." --piranha<br><br><br>------------------------------<br><br>Message: 2<br>Date: Fri, 10 Jul 2009 09:58:45 PDT<br>From: Bill Janssen &lt;janssen@parc.com&gt;<br>To: David Berthelot &lt;d_berthelot@yahoo.com&gt;<br>Cc: baypiggies@python.org<br>Subject: Re: [Baypiggies] Help ! How to exchange python objects<br><span class="Apple-tab-span" style="white-space:pre">        </span>between two<span class="Apple-tab-span" style="white-space:pre">        </span>python processes on the same machine ?<br>Message-ID: &lt;43480.1247245125@parc.com&gt;<br><br>David Berthelot &lt;d_berthelot@yahoo.com&gt; wrote:<br><br><blockquote type="cite">Ok, I'm trying to send some python objects from one Python process to another, on the same machine.<br></blockquote><br>Try "mmap", for inter-process, and "Queue", for intra-process (between<br>threads). &nbsp;Both in the standard library. &nbsp;Probably want to pickle the<br>data before writing it -- use a Pickler on the write side, and an<br>Unpickler on the read side.<br><br>Bill<br><br><br>------------------------------<br><br>Message: 3<br>Date: Fri, 10 Jul 2009 22:51:31 +0530<br>From: Harish Mallipeddi &lt;harish.mallipeddi@gmail.com&gt;<br>To: Bill Janssen &lt;janssen@parc.com&gt;<br>Cc: baypiggies@python.org<br>Subject: Re: [Baypiggies] Help ! How to exchange python objects<br><span class="Apple-tab-span" style="white-space:pre">        </span>between two<span class="Apple-tab-span" style="white-space:pre">        </span>python processes on the same machine ?<br>Message-ID:<br><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;e01b80590907101021m7d55d860m461f3f2d32b2f3a6@mail.gmail.com&gt;<br>Content-Type: text/plain; charset="iso-8859-1"<br><br>On Fri, Jul 10, 2009 at 10:28 PM, Bill Janssen &lt;janssen@parc.com&gt; wrote:<br><br><blockquote type="cite">David Berthelot &lt;d_berthelot@yahoo.com&gt; wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">Ok, I'm trying to send some python objects from one Python process to<br></blockquote></blockquote><blockquote type="cite">another, on the same machine.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Try "mmap", for inter-process, and "Queue", for intra-process (between<br></blockquote><blockquote type="cite">threads). &nbsp;Both in the standard library. &nbsp;Probably want to pickle the<br></blockquote><blockquote type="cite">data before writing it -- use a Pickler on the write side, and an<br></blockquote><blockquote type="cite">Unpickler on the read side.<br></blockquote><blockquote type="cite"><br></blockquote><br>You could also use "processing" to exchange objects between processes.<br><br>http://pypi.python.org/pypi/processing<br><br>-- <br>Harish Mallipeddi<br>http://blog.poundbang.in<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: &lt;http://mail.python.org/pipermail/baypiggies/attachments/20090710/2ee581ad/attachment-0001.htm&gt;<br><br>------------------------------<br><br>Message: 4<br>Date: Fri, 10 Jul 2009 10:29:23 -0700<br>From: Aahz &lt;aahz@pythoncraft.com&gt;<br>To: baypiggies@python.org<br>Subject: Re: [Baypiggies] Help ! How to exchange python objects<br><span class="Apple-tab-span" style="white-space:pre">        </span>between<span class="Apple-tab-span" style="white-space:pre">        </span>two<span class="Apple-tab-span" style="white-space:pre">        </span>python processes on the same machine ?<br>Message-ID: &lt;20090710172923.GA11768@panix.com&gt;<br>Content-Type: text/plain; charset=us-ascii<br><br>On Fri, Jul 10, 2009, Harish Mallipeddi wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">You could also use "processing" to exchange objects between processes.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">http://pypi.python.org/pypi/processing<br></blockquote><br>That's the same thing as the module multiprocessing, for versions of<br>Python prior to 2.6.<br>-- <br>Aahz (aahz@pythoncraft.com) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;*&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.pythoncraft.com/<br><br>"as long as we like the same operating system, things are cool." --piranha<br><br><br>------------------------------<br><br>Message: 5<br>Date: Fri, 10 Jul 2009 23:07:43 +0530<br>From: Harish Mallipeddi &lt;harish.mallipeddi@gmail.com&gt;<br>To: Aahz &lt;aahz@pythoncraft.com&gt;<br>Cc: baypiggies@python.org<br>Subject: Re: [Baypiggies] Help ! How to exchange python objects<br><span class="Apple-tab-span" style="white-space:pre">        </span>between two<span class="Apple-tab-span" style="white-space:pre">        </span>python processes on the same machine ?<br>Message-ID:<br><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;e01b80590907101037k235acd6fw69229d8bbe8be895@mail.gmail.com&gt;<br>Content-Type: text/plain; charset="iso-8859-1"<br><br>On Fri, Jul 10, 2009 at 10:59 PM, Aahz &lt;aahz@pythoncraft.com&gt; wrote:<br><br><blockquote type="cite">On Fri, Jul 10, 2009, Harish Mallipeddi wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">You could also use "processing" to exchange objects between processes.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">http://pypi.python.org/pypi/processing<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">That's the same thing as the module multiprocessing, for versions of<br></blockquote><blockquote type="cite">Python prior to 2.6.<br></blockquote><blockquote type="cite">--<br></blockquote><blockquote type="cite">Aahz (aahz@pythoncraft.com) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;*&gt;<br></blockquote><blockquote type="cite">http://www.pythoncraft.com/<br></blockquote><blockquote type="cite"><br></blockquote><br>My bad - didn't read the entire thread before answering :)<br><br>-- <br>Harish Mallipeddi<br>http://blog.poundbang.in<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: &lt;http://mail.python.org/pipermail/baypiggies/attachments/20090710/b2f3164a/attachment-0001.htm&gt;<br><br>------------------------------<br><br>Message: 6<br>Date: Fri, 10 Jul 2009 10:40:49 -0700 (PDT)<br>From: David Berthelot &lt;d_berthelot@yahoo.com&gt;<br>To: Aahz &lt;aahz@pythoncraft.com&gt;, baypiggies@python.org<br>Subject: Re: [Baypiggies] Help ! How to exchange python objects<br><span class="Apple-tab-span" style="white-space:pre">        </span>between two<span class="Apple-tab-span" style="white-space:pre">        </span>python processes on the same machine ?<br>Message-ID: &lt;592466.96345.qm@web57614.mail.re1.yahoo.com&gt;<br>Content-Type: text/plain; charset="us-ascii"<br><br>Thanks for all the answers, I forgot to mention that the speed of transfer between processes is an import factor, so hard-disk files are out of the question.<br><br>So I'm going to look into 3 proposed solutions:<br>1. mmap [+ cpickle]<br>2. processing<br>3. xmlrpc (this one is least clear to me, it looks like it needs some server to run, I just need to look more into it).<br><br>Thanks,<br><br>David<br><br><br><br><br>________________________________<br>From: Aahz &lt;aahz@pythoncraft.com&gt;<br>To: baypiggies@python.org<br>Sent: Friday, July 10, 2009 10:29:23 AM<br>Subject: Re: [Baypiggies] Help ! How to exchange python objects between two python processes on the same machine ?<br><br>On Fri, Jul 10, 2009, Harish Mallipeddi wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">You could also use "processing" to exchange objects between processes.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">http://pypi.python.org/pypi/processing<br></blockquote><br>That's the same thing as the module multiprocessing, for versions of<br>Python prior to 2.6.<br>-- <br>Aahz (aahz@pythoncraft.com) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;*&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.pythoncraft.com/<br><br>"as long as we like the same operating system, things are cool." --piranha<br>_______________________________________________<br>Baypiggies mailing list<br>Baypiggies@python.org<br>To change your subscription options or unsubscribe:<br>http://mail.python.org/mailman/listinfo/baypiggies<br><br><br><br><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: &lt;http://mail.python.org/pipermail/baypiggies/attachments/20090710/d6dd97d1/attachment.htm&gt;<br><br>------------------------------<br><br>_______________________________________________<br>Baypiggies mailing list<br>Baypiggies@python.org<br>To change your subscription options or unsubscribe:<br>http://mail.python.org/mailman/listinfo/baypiggies<br><br>End of Baypiggies Digest, Vol 45, Issue 14<br>******************************************<br></div></blockquote></div><br></div></div></body></html>