473,320 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Jun 27 '08 #1
6 2688
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.
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
Jun 27 '08 #2
Guillermo wrote:
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

Jun 27 '08 #3
On Jun 3, 10:07 pm, Guillermo <guillermo.lis...@googlemail.comwrote:
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/
Jun 27 '08 #4
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 **
Jun 27 '08 #5

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.
Jun 27 '08 #6
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/pyth...ase/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
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
4
by: John Ramsden | last post by:
I have a PHP script that is run via a 'wget' command within an MS SQL trigger, and relies on accessing the database record updated by the SQL statement that triggered the script in the first...
7
by: Arun | last post by:
Hi, This is a scripting question, but since I am writing the script in python I am posting this question here: I have a python script that runs a simulator (that was written in c++, so I use...
3
by: Harlin Seritt | last post by:
Hi, I have a script.py that is converted to .exe using py2exe. From another script I call script.exe and would like to be able to run this script.exe in the background (as well as in console --...
5
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. ...
1
by: john woo | last post by:
Hi I'm not good at JS, but want to get more about it. I want to use a JSP (the java code just used to get date, the rest are html and javascript), to display a table. the requirement is the...
10
by: Nimit | last post by:
Hi, I wasn't sure which forum this post belongs to, so I've posted it to a couple forums that I thought may be appropriate. In giving me advice, please consider me a beginner. Below is a synopsis...
2
by: Jonah Bishop | last post by:
What is the appropriate way to start a PHP script in the background? I have a script that manipulates image data, and it takes a long time to run. I'd like to send this process to the background at...
3
by: sophie_newbie | last post by:
Hi, I have a cgi script that performs a very long computation that can take several hours to complete. Is there any smart way that I can keep this script running until it is finished (after the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.