Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old June 27th, 2008, 05:27 PM
Guillermo
Guest
 
Posts: n/a
Default Keep a script running in the background


Hi,

I need a script to keep running in the background after it's loaded
some data. It will make this data available to the main program in the
form of a dictionary, but I don't want to reload the calculated data
every time the user needs it via the main program.

I won't be working with an UI, hope that can be made easily in Python
somehow.

Cheers,

Guillermo
  #2  
Old June 27th, 2008, 05:27 PM
Daniel Fetchinson
Guest
 
Posts: n/a
Default Re: Keep a script running in the background

I need a script to keep running in the background after it's loaded
Quote:
some data. It will make this data available to the main program in the
form of a dictionary, but I don't want to reload the calculated data
every time the user needs it via the main program.
>
I won't be working with an UI, hope that can be made easily in Python
somehow.
I'm not sure I understand exactly what you want but you might find
these daemonize examples useful from the cookbook:

http://aspn.activestate.com/ASPN/Coo.../Recipe/278731
http://aspn.activestate.com/ASPN/Coo...n/Recipe/66012

Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
  #3  
Old June 27th, 2008, 05:27 PM
Bjoern Schliessmann
Guest
 
Posts: n/a
Default Re: Keep a script running in the background

Guillermo wrote:
Quote:
I need a script to keep running in the background after it's
loaded some data. It will make this data available to the main
program in the form of a dictionary, but I don't want to reload
the calculated data every time the user needs it via the main
program.
>
I won't be working with an UI, hope that can be made easily in
Python somehow.
Sure. Try the subprocess module.

Regards,


Björn

--
BOFH excuse #205:

Quantum dynamics are affecting the transistors

  #4  
Old June 27th, 2008, 05:27 PM
subeen
Guest
 
Posts: n/a
Default Re: Keep a script running in the background

On Jun 3, 10:07 pm, Guillermo <guillermo.lis...@googlemail.comwrote:
Quote:
Hi,
>
I need a script to keep running in the background after it's loaded
some data. It will make this data available to the main program in the
form of a dictionary, but I don't want to reload the calculated data
every time the user needs it via the main program.
>
I won't be working with an UI, hope that can be made easily in Python
somehow.
>
Cheers,
>
Guillermo
You can try this command: nohup python script.py &

regards,
Subeen.
http://love-python.blogspot.com/
  #5  
Old June 27th, 2008, 05:27 PM
Tobiah
Guest
 
Posts: n/a
Default Re: Keep a script running in the background

Quote:
I need a script to keep running in the background after it's loaded
some data. It will make this data available to the main program in the
form of a dictionary, but I don't want to reload the calculated data
every time the user needs it via the main program.
If it were me, I'd go with a database server like mysql.
** Posted from http://www.teranews.com **
  #6  
Old June 27th, 2008, 05:27 PM
Guillermo
Guest
 
Posts: n/a
Default Re: Keep a script running in the background


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.
  #7  
Old June 27th, 2008, 05:27 PM
M.-A. Lemburg
Guest
 
Posts: n/a
Default Re: Keep a script running in the background

On 2008-06-04 01:33, Guillermo wrote:
Quote:
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/pyth...ase/mxBeeBase/

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source (#1, Jun 04 2008)
Quote:
Quote:
Quote:
>>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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles