On Tue, Feb 17, 2009 at 7:56 AM, Paul Geeleher <paulgeele...@gmail.com> wrote: > I've got a series of python cgi scripts that do various operations on > data in an r session via rpy. The only problem is that when each > script finishes, it has to save the manipulated r session to disk and > the next script has to load the r session from disk, which can be > quite time consuming. > > So what I'm wondering is if there is any way of persisting my r > object, loaded using "from rpy import r" in memory for a certain > period of time after a cgi scripts execution ends, to be picked up by > the next script, so as to save the time it takes to repeatedly write > my session to and read it from the hard disk?
The fundamental problem is unfortunately baked into how CGI works -- when your web server receives a CGI request, then it loads up your script, runs it, and then kills it. So there's very little your script can do to persist anything in memory... its memory is getting wiped out at the end of the request! Lots of people have run into this problem before (e.g., basically everyone writing web apps in python), and the main solution is to stop using CGI and switch to something like SCGI or FastCGI. This might be more complicated than you want to deal with (it's definitely too complicated to explain in a quick mailing list post), but there are lots of docs out there, and lots of existing python libraries. I'd start by googling "scgi" and "python scgi". Good luck... -- Nathaniel ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list