[mod_python] All spawned threads in Restricted Exection Mode

Graham Dumpleton grahamd at dscpl.com.au
Wed Mar 30 23:01:05 EST 2005


Possibly not much too different to:

  http://www.modpython.org/pipermail/mod_python/2005-January/017129.html

Both the earlier one and your one work for me under:

  mod_python: Creating 32 session mutexes based on 6 max processes and 25 max threads.

Ie., Mac OS X, worker MPM.

The previous poster didn't say what platform they were one from I
can see. Can someone else on Win32 platform try both these examples?

Graham

Alan Davies wrote ..
> Mine is a very simple arrangement, there's not even any need to bring
> PIL
> into the picture to reproduce the problem. I've written a short example
> script
> attempts to open a file, which is just one of the many things not
> possible
> in restricted mode.
> 
> The script can be run here:
> 
> http://goatpunch.com:8080/flow/threadtest.py
> 
> The output is:
> 
> In main thread: file() was OK
> In child thread: file() threw exception: file() constructor not
> accessible in restricted mode
> 
> 
> ------ threadtest.py ------
> 
> import threading, time, mod_python
> 
> def openfiletest(req):
>     try:
>         a = file("test", "w")
>         req.write("file() was OK\n") 
>     except Exception, e:
>         req.write("file() threw exception: " + str(e) + "\n")
> 
> def handler(req):
>     req.write("In main thread: ")
>     openfiletest(req)
>     req.write("In child thread: ")
>     t = threading.Thread(target=openfiletest, args=(req,) )
>     t.start()
>     time.sleep(1)
>     return mod_python.apache.OK
> 
> ---------------------------
> 
> 
> I added the following to httpd.conf to execute the above script:
> 
> 
> <Directory "C:/[...]/htdocs/flow">
> 
>   Options Indexes FollowSymLinks
>   AllowOverride None
>   Order allow,deny
>   Allow from all
> 
>   AddHandler python-program .py
>   PythonDebug On 
> 
>   <Files threadtest.py>
>       PythonPath "['C:/[...]/htdocs/flow'] + sys.path"
>       PythonHandler threadtest
>   </Files>
> </Directory>
> 
> 
> Thanks for any help or advice you're able to offer- let me know if
> you have any ideas for other code I could run to help narrow down
> this problem.
> 
> --Alan


More information about the Mod_python mailing list