durusmail: quixote-users: apache 2 mod_scgi double execution puzzle.
apache 2 mod_scgi double execution puzzle.
apache 2 mod_scgi double execution puzzle.
cmulcahy@avesi.com
2005-03-10
I am sorry that this message is not Quixote related, but I couldn't find
another venue for scgi.

I have a very simple scgi-handler that I am experimenting with as a
means of accelerating a large number of legacy python cgi-scripts with
minimal modification.

Essentially, the handler is grabbing marshal'ed code objects from a
cdb-file and exec-ing them in a prepared environment.  ( Note this is
just a proof of concept that exec's the same object code every time, and
does no meaningful error-checking )


from scgi import scgi_server

from cdb import init as cdbInit
from marshal import loads

import cgi

class myhandler(scgi_server.SCGIHandler):

 def handle_connection(self, conn):

      print "handling connection"

      input = conn.makefile("r")
      output = conn.makefile("w")

      env = self.read_env(input)

      code = loads(cdbInit('/tmp/scgi.cdb')['mkm'])

      exec(code,{'input':input, 'output':output, 'env':env, 'cgi':cgi})

      input.close()
      output.close()

Everything appears to work fine when tested from a browser ( and with
enormous performance improvements ).

However, when run in the foreground, I notice that the line "handling
connection" gets printed twice for every connection, leading me to
believe that handle_connection is being called twice.

Any ideas?







--
Christopher Mulcahy
Avenir Solutions
508.520.9976


reply