[mod_python] mod_python and threading.Thread doesn't start

Alexey Melchakov melchakov at gmail.com
Mon Jun 6 07:14:47 EDT 2005


You were right, it's all about restricted mode. Is there any solvation
for this problem?

Output:

In main thread: file() was OK
In child thread: file() threw exception: file() constructor not
accessible in restricted mode



On 6/6/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> 
> 
> On 06/06/2005, at 5:39 PM, Alexey Melchakov wrote:
> 
> Try the following code instead so that you can see if a Python
> exception is
> being raised within the thread. One possibility is that you might be
> running
> up against a strange problem seen by a few people which hasn't really
> been
> worked out yet. One previous post where someone had this problem was:
> 
> http://www.modpython.org/pipermail/mod_python/2005-January/017129.html
> 
> for more details.
> 
> Anyway, let us know what the following produces.
> 
> 
> import threading
> import time
> from mod_python import apache
> 
> def openfiletest(req):
> try:
> a = file("/tmp/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 apache.OK
> 
> 
> 
-- 
melchakov at gmail.com
CRV-RIPN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050606/7eff8250/attachment.html


More information about the Mod_python mailing list