[mod_python] All spawned threads in Restricted Exection Mode

Mike Solomon mike at mrlventures.com
Sun Apr 10 18:35:21 EDT 2005


Yes, it was several hours after I made that post that I located this 
gem, which pointed me in that direction.

http://mail.python.org/pipermail/python-bugs-list/2005-March/028011.html

I haven't made any commitments to python 2.4 yet, so it looks like I'll 
just have to wait.

Thanks for the pointer.

-ms

On Apr 10, 2005, at 1:20 PM, Alan Davies wrote:

> If you don't need the features of Python 2.4, you could try going back
> to Python 2.3.4 (not 2.3.5), which is how I have avoided the problem
> for now.
>
> --Alan
>
> On Sat, 9 Apr 2005 14:06:02 -0700, "Mike Solomon" 
> <mike at mrlventures.com>
> said:
>> I too see this problem and it's driving me bananas.
>>
>> I've got Apache 2.0.53, mod_python 3.1.4, python 2.4 installed under
>> SuSE 9.1. My servlet code and apache config are exactly the same as
>> Alan's (to minimize potential setup variables.)
>>
>> My specific problem is that pickling causes this unmarshal error:
>>
>> (it doesn't seem to matter what i pickle, or if i use cPickle vs 
>> pickle)
>>
>> Traceback (most recent call last):
>>    File "/home/msolomon/test/zclient/client.py", line 10, in
>>    RuntimeError: cannot unmarshal code objects in restricted execution
>> mode
>>
>> That line looks like this:
>>   9:  obj = None
>> 10:  in_a_pickle = pickle.dumps(obj, 2)
>>
>>
>> Now here is a very strange observation - this exception does not occur
>> if I put the contents of client.py into threadtest.py - it only 
>> happens
>> when the code is imported.
>>
>> I'm not sure why threads appear to be executing in restricted mode -
>> but if that is the problem, I guess I'd like to know how to turn that
>> off.  Despite stumbling onto a few occurrences of this problem, I have
>> yet to see a solution posted anywhere.
>>
>> If either of you gentlemen have any additional insight, I would
>> appreciate it.
>>
>> ------
>>
>> My servlet looks like this (threadtest.py):
>>
>> import mod_python
>> from zclient.client import Client
>>
>> def handler(req):
>>    c = Client()
>>    req.write(str(c.perform()))
>>    return mod_python.apache.OK
>>
>>
>> This is zclient/client.py:
>>
>> import cPickle as pickle
>> import threading, traceback
>>
>> class Client:
>>    def thread_op(self, results):
>>      try:
>>        obj = None
>>        in_a_pickle = pickle.dumps(obj, 2)
>>        results.append('ok')
>>      except Exception, e:
>>        results.extend(traceback.format_exc().split('\n'))
>>
>>    def perform(self):
>>      results = []
>>      t = threading.Thread(target=self.thread_op, args=(results,))
>>      t.start()
>>      t.join()
>>      return str(results)
>>



More information about the Mod_python mailing list