Keep a script running in the background

M.-A. Lemburg mal at egenix.com
Wed Jun 4 04:43:14 EDT 2008


On 2008-06-04 01:33, Guillermo wrote:
> These are the basic requirements:
> 
> Script A must keep a dictionary in memory constantly and script B must
> be able to access and update this dictionary at any time. Script B
> will start and end several times, but script A would ideally keep
> running until it's explicitly shut down.
> 
> I have the feeling the way to do this is Python is by pickling the
> dict, but I need the method that gives the best performance. That's
> why I'd rather want to keep it in memory, since I understand pickling
> involves reading from and writing to disk.
> 
> I'm using SQLite as a database. But this dict is an especial index
> that must be accessed at the highest speed possible.

If you're on Unix, it's easiest to have script A implement a
signal handler. Whenever it receives a signal, it rereads the
pickled dict from the disk. Script B then writes a new revision
of the dict and sends the signal to script A.

Alternatively, you could use an on-disk dictionary like e.g.
mxBeeBase:

https://www.egenix.com/products/python/mxBase/mxBeeBase/

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jun 04 2008)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2008-07-07: EuroPython 2008, Vilnius, Lithuania            32 days to go

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the Python-list mailing list