Simple Python App Server

T

tom.purl

I use the pyGTD script to manage my todo lists and such. From Vim, I
shell out a call to the gtd.py script, which updates my todo.txt file
after update one of the related pyGTD files. Since I make a lot of
updates to the related pyGTD files, I execute the gtd.py script dozens
of times a day.

The problem is that this script can be a little slow. It usually takes
at least 5 seconds to run, time that I can't use Vim (and running it in
the background from Vim isn't a usable option for me). I tried making
it run faster by adding the following lines at the top of the __main__
method:

import psyco
psyco.full()

This change, however, didn't shave off any noticeable amount of time.

I was wondering if there was a way in which I could run the python
interpreter all of the time so that I wouldn't have to invoke it each
time that I want to run the gtd.py script. Is there a way to do this?o

Thanks in advance!

Tom Purl
 
N

Neil Cerutti

I use the pyGTD script to manage my todo lists and such. From
Vim, I shell out a call to the gtd.py script, which updates my
todo.txt file after update one of the related pyGTD files.
Since I make a lot of updates to the related pyGTD files, I
execute the gtd.py script dozens of times a day.

Was your Vim compiled with the +python feature (this enables
several Vim commands to run python code directly in Vim)? I
don't know if that would speed things up or not, but it's worth a
try.

If the feature is present, you can run a Python script with the
:pyfile command.
 
D

Diez B. Roggisch

tom.purl said:
I use the pyGTD script to manage my todo lists and such. From Vim, I
shell out a call to the gtd.py script, which updates my todo.txt file
after update one of the related pyGTD files. Since I make a lot of
updates to the related pyGTD files, I execute the gtd.py script dozens
of times a day.

The problem is that this script can be a little slow. It usually takes
at least 5 seconds to run, time that I can't use Vim (and running it in
the background from Vim isn't a usable option for me). I tried making
it run faster by adding the following lines at the top of the __main__
method:

import psyco
psyco.full()

This change, however, didn't shave off any noticeable amount of time.

I was wondering if there was a way in which I could run the python
interpreter all of the time so that I wouldn't have to invoke it each
time that I want to run the gtd.py script. Is there a way to do this?o


Sure. Just enter a loop. Incidentially, common application server
frameworks as SimpleXMLRPC or pyro come with a main event loop which
will of course prevent the interpreter to stop.

Together with the daemonize-recipe from apsn, you have your server.

I suggest you use pyro - that will most probably cause the least fuss.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top