473,289 Members | 1,917 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,289 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 2685
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.