Keep script in memory & quick "recall"?
#1
I'd like to have a script load into memory and stay resident with the ability to recall it onscreen with a button press. Thus, removing the long load time and the need to navigate to the script to open it every time.

Is this possible?
I'm not an expert but I play one at work.
Reply
#2
Best bet would be to do a client/server model. First time you start your script you start the server then connect, future calls you just connect to it.
Reply
#3
althekiller Wrote:Best bet would be to do a client/server model. First time you start your script you start the server then connect, future calls you just connect to it.

Any example code you can point me to? It has been 2 years since I touched Python and I wes no expert back then Wink
I'm not an expert but I play one at work.
Reply
#4
I'm not certain exactly what althekiller had in mind, but I've used the "socket" library in the past to set up socket connections. Every time you run your script (whatever responds to the keypress, that is), it tries to contact the server, and if no server is available it runs the script that launches the server.

The server then sits and listens on a certain port for recognized commands. When it receives a command (probably an info request), it establishes a connection and returns whatever information you want from it.

On the keypress, then, you would just launch a client that connects to the server, gets whatever information it's providing, and then displays it.

You can probably find much better generic examples of socket connections searching for "Python socket," but you can find a specific implementation of it in my very old (and, I'm sure, completely obsolete) XMonitor script.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#5
I wonder if such complexity is necessary for my goal?

The script is my HomeControl script that polls the Homeseer software (currently on the same PC as XBMC) for status of devices (lights, etc). Then it displays a GUI to change the device states (on/off/dim/etc).

The issue I want to solve is time to load the script. It takes a while to do the initial load.

I was thinking if I loaded it on XBMC's boot, and then could just have it sit in the background... then "call" it to the foreground only when needed - via a keypress - this would allow it to sit in memory running so no load time is required.

Does this make things easier? Any thoughts?
I'm not an expert but I play one at work.
Reply
#6
the 'sits in the background' part is what they, and most ppl, call a server.

you then have a lightweight script talking to that background server which polls the info. that way you can keep the connection to the backend open so you dont have to init it all the time hence hopefully shaving off enough on the startup time of the 'interactive' part of your script. the background server could even poll the backend at regular intervals if that is something that fits here, that way the 'interactive' part would be even faster
Reply

Logout Mark Read Team Forum Stats Members Help
Keep script in memory & quick "recall"?0