Simple Python App Server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tom.purl

    #1

    Simple Python App Server

    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

  • Neil Cerutti

    #2
    Re: Simple Python App Server

    On 2006-08-18, tom.purl <tom.purl@gmail .comwrote:
    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.

    --
    Neil Cerutti

    Comment

    • Diez B. Roggisch

      #3
      Re: Simple Python App Server

      tom.purl schrieb:
      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

      Comment

      Working...