[mod_python] restricted mode in server cleanup callback?

Stéphane Bidoul stephane.bidoul at softwareag.com
Mon Apr 26 16:35:28 EST 2004


Hi,

I'm having problems with server cleanup callbacks
(on windows, with apache 2.0.49 and mod_python 3.1.3):

For instance, with

def endChild(data):
    f = file("test.log","a")
    try:
       print >> f, "endChild", data
    finally:
       f.close()

firstTime = 1

def handler(req):
    if firstTime:
        global firstTime
        req.server.register_cleanup(req,endChild,("endChild data",)
        firstTime = 0

Sometimes, the endChild function runs normally,
but sometimes, I get this in apache error.log:

[notice] Child 1284: Exit event signaled. Child process is ending.
[notice] Child 1284: Released the start mutex
[notice] Child 1284: Waiting for 250 worker threads to exit.
[notice] Child 1284: All worker threads have exited.
[error] python_cleanup: Error calling cleanup object <function endChild at
0x005FFC30>
[error]     exceptions.IOError: file() constructor not accessible in
restricted mode
[notice] Child 1284: Child process is exiting
[notice] Parent: Child process exited successfully.

Why is python thinking it is in restricted mode?
I'm prepared to launch my debugger, but I've no clue
where to search first, so any hint is most welcome.

Thanks in advance.

-sbi



More information about the Mod_python mailing list