John R. Wallace
jwallace at woti.com
Tue Jan 18 11:22:53 EST 2005
Hello all, I am using both threads and mod_python in my current project, and it appears that any new threads that I start are running in restricted mode by default. I was wondering if anyone has ever seen this, and/or how I can get my threads to run in "normal" mode, so that they have access to things like the file() constructor, for example. Below is a small toy example that illustrates the problem that I am having: ----------------------- from mod_python import apache, util import threading import os def run(request): try: os.system("ls") x = file("/tmp/test", "w") x.write("Writing! look at me!") x.close() except Exception, e: request.write("Oh no, exception in thread! " + str(e) + "\n") def handler(request): request.content_type = "text/plain" request.send_http_header() thread = threading.Thread(target=run, args=(request,)) thread.start() thread.join() try: x = file("/tmp/test", "w") x.write("Writing! look at me!") request.write("Wrote to file") x.close() except Exception, e: request.write("Oh no, exception! " + str(e) + "\n") return apache.OK ------------------ Running this code will result in: Oh no, exception in thread! file() constructor not accessible in restricted mode Wrote to file anyone have any brilliant ideas on how to disable the restricted mode? BTW, if you've read this far, I'm running mod_python 3.1.3, Python 2.4, and apache 2.0.52 Thank you for your help, John
|