I run MoinMoin on my site. I have a gdchart module (gdchart.so
library) that seems to work for MoinMoin's charting purposes, and I
have been using it in this context for some time. However, this module
was built with an older Python so whenever it is imported, Python
issues
RuntimeWarning: Python C API version mismatch for module gdchart: This
Python has API version 1012, module gdchart has version 1011.
In order to suppress this warning I added
# supress gdchart API warning
from warnings import filterwarnings
filterwarnings('ignore', 'Python C API version mismatch',
RuntimeWarning)
to my MoinMoin configuration file wikiconfig.py. This was effective
when I was running MoinMoin as a CGI.
Problem:
I have changed to running MoinMoin via WSGI and the suppression is no
longer effective. I am running WSGI in daemon mode with the following
in httpd.conf
WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess wsgi-gpc user=gpc group=gpc home=/var/www/grizz
umask=0002 display-name=wsgi-gpc
WSGIProcessGroup wsgi-gpc
WSGIScriptAlias /gpc "/var/www/grizz/moin/gpc/moin.wsgi"
When the daemon starts, the first web interaction issues
[error] /usr/lib/python2.4/site-packages/MoinMoin/config/
multiconfig.py:305: RuntimeWarning: Python C API version mismatch for
module gdchart: This Python has API version 1012, module gdchart has
version 1011.
I even tried adding
# supress gdchart API warning
from warnings import filterwarnings
filterwarnings('ignore', 'Python C API version mismatch',
RuntimeWarning)
to the beginning of the moin.wsgi script, but I still get the warning
message.
The warning itself is not a big deal, but my inability to suppress it
indicates there is something I don't understand and that is what
concerns me.
This is Apache 2.3, Python 2.4.3, mod_wsgi 3.1 and I do not load
mod_python.
- C
> --
>
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>
>
Thanks for your reply.
Please note that this question is not about gdchart per se. The
question is why can't I suppress a warning message by calling
warnings.filterwarnings()
Since posting this question I have stumbled across the new in wsgi 3.0
WSGIPythonWarnings directive, and I understand that that would
probably be effective in suppressing this warning, although I haven't
tried it. But the question still remains - why is a call to
warnings.filterwarnings() from the wsgi script not effective?
Also, I would dearly love to compile gdchart in my current Python
environment. Do you know where I can find the source?
From memory because warnings.filterwarnings() only works when used in
main Python interpreter and doesn't work in sub interpreters.
You can test this theory by forcing your application to run in main
Python interpreter using:
WSGIApplicationGroup %{GLOBAL}
You'll only really be able to do this if hosting the one application
in embedded mode, or only if delegating each application to separate
daemon mode process group.
WSGIPythonWarnings will work because it does its work even before
Python initialised and the settings it configures will be correctly
inherited by Python sub interpreters.
As to the warning, you are best off trying to get hold of source and
recompiling for correct version of Python.
Graham