[mod_python] All spawned threads in Restricted Exection Mode

Alan Davies alan at goatpunch.com
Thu Mar 31 00:58:01 EST 2005


I tried some tests with different versions of Apache/Python/mod_python,
and narrowed it down to Python version 2.3.5 or later:

Apache/2.0.44 (Win32) mod_python/3.0.3 Python/2.2.3 - OK
Apache/2.0.53 (Win32) mod_python/3.1.3 Python/2.3.4 - OK
Apache/2.0.44 (Win32) mod_python/3.1.3 Python/2.3.5 - Fails
Apache/2.0.53 (Win32) mod_python/3.1.3 Python/2.3.5 - Fails
Apache/2.0.53 (Win32) mod_python/3.1.4 Python/2.4 - Fails

Looking for information to do with 2.3.5, I found that this bug has
already been logged:

http://sourceforge.net/tracker/index.php?func=detail&aid=1163563&group_id=5470&atid=105470

Not sure whether this is a Win32-only problem.

I'm going back to version 2.3.4 as I don't know enough about the
internals of python to fix this, and threads are useful things to have
working.

Thanks for your time,

--Alan

On Wed, 30 Mar 2005 23:01:05 -0500, "Graham Dumpleton"
<grahamd at dscpl.com.au> said:
> 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