Problems with TG2 + mod_wsgi

219 views
Skip to first unread message

Luke Macken

unread,
Jun 7, 2009, 12:56:15 AM6/7/09
to TurboGears
Hey guys,

I'm hitting the following traceback when trying to deploy a
TurboGears2 app with mod_wsgi. Any help would be much appreciated.

WSGIDaemonProcess fedoracommunity user=apache maximum-requests=1000
display-name=fedoracommunity processes=1 threads=1

[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] mod_wsgi
(pid=1245): Target WSGI script '/usr/share/fedoracommunity/
fedoracommunity.wsgi' cannot be loaded as Python module.
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] mod_wsgi
(pid=1245): Exception occurred processing WSGI script '/usr/share/
fedoracommunity/fedoracommunity.wsgi'.
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] Traceback (most
recent call last):
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
share/fedoracommunity/fedoracommunity.wsgi", line 9, in ?
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] application
= loadapp('config:/etc/fedoracommunity/production.ini')
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/paste/deploy/loadwsgi.py", line 204, in
loadapp
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] return
loadobj(APP, uri, name=name, **kw)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/paste/deploy/loadwsgi.py", line 225, in
loadobj
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] return
context.create()
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/paste/deploy/loadwsgi.py", line 625, in
create
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] return
self.object_type.invoke(self)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/paste/deploy/loadwsgi.py", line 110, in
invoke
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] return
fix_call(context.object, context.global_conf, **context.local_conf)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/paste/deploy/util/fixtypeerror.py", line
57, in fix_call
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] val =
callable(*args, **kw)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/fedoracommunity/config/middleware.py",
line 26, in make_app
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99]
full_stack=full_stack,
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/tg/configuration.py", line 604, in
make_base_app
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] app =
self.add_tm_middleware(app)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/tg/configuration.py", line 531, in
add_tm_middleware
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] from
repoze.tm import make_tm
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/repoze/tm/__init__.py", line 2, in ?
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] import
transaction
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/transaction/__init__.py", line 19, in ?
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] from
transaction._transaction import Transaction
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/transaction/_transaction.py", line 625,
in ?
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] class
Savepoint:
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/zope/interface/advice.py", line 132, in
advise
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] return
callback(newClass)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/zope/interface/declarations.py", line 484,
in _implements_advice
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99]
classImplements(cls, *interfaces)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/zope/interface/declarations.py", line 460,
in classImplements
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] spec =
implementedBy(cls)
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] File "/usr/
lib/python2.4/site-packages/zope/interface/declarations.py", line 300,
in implementedByFallback
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] spec =
cls.__dict__.get('__implemented__')
[Sun Jun 07 04:45:18 2009] [error] [client 10.8.34.99] RuntimeError:
class.__dict__ not accessible in restricted mode

Graham Dumpleton

unread,
Jun 7, 2009, 6:48:44 AM6/7/09
to TurboGears
Set:

WSGIApplicationGroup %{GLOBAL}

This will force your TG instance to run in Python main interpreter.

This is needed in your case as you appear to be using a third party C
extension module for Python which isn't implemented properly to allow
it to be used in Python sub interpreters. Ie., it would like it will
only work in the Python main interpreter.

That this is the problem is suggested by the error:

RuntimeError: class.__dict__ not accessible in restricted mode

which can come about when certain types of Python objects are reused
in a Python interpreter they were not originally created for.

Anyway, give that a try.

Graham

Luke Macken

unread,
Jun 7, 2009, 3:22:15 PM6/7/09
to TurboGears
This seemed to do the trick! Thank you Graham for your help, and for
all of your great work on mod_wsgi.

Cheers,

luke

On Jun 7, 6:48 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:

Luke Macken

unread,
Jun 7, 2009, 3:27:31 PM6/7/09
to TurboGears
Does doing this impose any sort of limitations on other apps running
on the same system? Will I still be able to tweak the processes/
threads of my daemon process?

Thanks,

luke

On Jun 7, 6:48 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:

Graham Dumpleton

unread,
Jun 8, 2009, 6:44:51 AM6/8/09
to TurboGears


On Jun 8, 5:27 am, Luke Macken <luke.mac...@gmail.com> wrote:
> Does doing this impose any sort of limitations on other apps running
> on the same system?  Will I still be able to tweak the processes/
> threads of my daemon process?

Not really. The only issue that can arise is that mod_wsgi by default
keeps each WSGI application in a distinct sub interpreter. Thus if
running multiple WSGI applications in the same daemon process group,
they would be kept separate. By overriding the sub interpreter used,
just have to be careful at what scope you do it as you may not want to
be forcing all WSGI applications into the main interpreter. Depending
on the applications, not all WSGI applications, or multiple instances
of same framework, will happily coexist in same interpreter. If each
WSGI application has its own daemon process group anyway, definitely
no problem.

Graham
Reply all
Reply to author
Forward
0 new messages