On 15.03.2011 21:45, Joonas Lehtolahti wrote:
>> As said above, I think not importing the "codecs" module by default is
>> the problem in my eyes. So the question is should mod_wsgi always
>> include this?
>
> The problem is that codecs doesn't get imported. I have also that
> problem in another project where Python is included into another
> software. Well, personally I don't have the problem but other people
> using the same software do have problem that "no codec lookup
> functions have been registered". Normally these modules are
> automatically loaded when the Python interpreter is initialized. For
> some yet unknown reason for some people embedded Python interpreters
> fail to do it. We have yet to find out what exactly causes the issue,
> but I had a theory.
>
> Well, Python initializes the encodings package, which imports codecs
> module. Now the interesting thing is that if any exception happens
> inside this encodings package importing during Python initialization,
> that error is just silently ignored. So in case for some reason
> importing the codecs module fails during initialization, there will be
> no signs of the error anywhere except that when a codec is needed you
> are faced with the error that there are no lookup functions available.
>
> Now, you could try to find out what the error actually is by wrapping
> the whole contents of encodings/__init__.py into a try: except:
> construct and dump the error to a file or something in the exception
> handler there. That should, in my theory, reveal where the error
> exactly happens. And if it does, please share the findings.
>
Tried that. Each of my four Apache processes imports
"encodings/__init__.py" as soon as I restart Apache ("service apache2
restart"), and the import runs without any exceptions!

Here is the output of sys.modules.keys() from the WSGI script (sorted
alphabetically):

('UserDict', '__builtin__', '__main__', '_abcoll',
'_mod_wsgi_a9b03b1837e0ae52d38b86c3232eac95', '_warnings', 'abc',
'apache', 'copy_reg', 'errno', 'genericpath', 'linecache', 'mod_wsgi',
'os', 'os.path', 'posix', 'posixpath', 'pwd', 'signal', 'site',
'sitecustomize', 'stat', 'sys', 'types', 'warnings', 'zipimport')

No "codecs" module here obviously. What I don't understand: Why is the
"encodings" module missing here? As said above, mod_wsgi seems to load
the "encodings" module somewhere when starting inside an Apache process.
Does it create a new interpreter for executing the WSGI script?

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to