[mod_python] Several handlers

export at hope.cz export at hope.cz
Sat Jan 13 10:34:42 EST 2007


Graham,
Thank you for your help.
Now Apache can find my inputinput filter.
Here it is:
################
from mod_python import apache
import os, shutil

def log(text):
    f = open('C:/Python23/Lib/site-packages/django/core/handlers/log', 'a')
    f.write(text)
    f.write('\n')
    f.close()
    
def inputfilter(filter):
    if filter.req.method != 'POST':
        filter.disable()
        return
    f=open('C:/Python23/Lib/site-packages/django/core/handlers/filter.log','ab')
    log('first read')
    s = filter.read()
    while s:
        log('writing (%s)' % len(s))
        f.write(s)
        f.flush()
        filter.write(s)
        log('loop read')
        filter.flush()
        s = filter.read()
    if s is None:
        log('closing')
        filter.close()
        raise "error"
      f.close()
################
But I would expect that it will read some data, write to a file and release the memory and 
again.
But it does NOT. As it reads more and more data more and more memory is used - no 
memory is released. As a result, python program  crashes because of little memory available.
Am I right if I suppose that the memory allocation should not increase during reading data?
Or am I wrong?
Thank you again for help
L.




More information about the Mod_python mailing list