Reputation: 1568
I'm trying to run Django wsgi application on on tornado server using tornado fallback
wsgi_app = tornado.wsgi.WSGIContainer(
django.core.wsgi.WSGIHandler()
)
tornado_app = tornado.web.Application(
[
(r"/hello/(.*)", HelloHandler),
('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app)),
]
)
server = tornado.httpserver.HTTPServer(tornado_app)
server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
but when I run this file, I got the following error:
django.core.wsgi.WSGIHandler()
AttributeError: 'module' object has no attribute 'wsgi'
Upvotes: 1
Views: 3199
Reputation: 22134
Please show the complete code including the imports. It looks like you just did import tornado
, not import tornado.wsgi
(and all the other modules). In python, you must import all the modules you need; you cannot import an entire package at once (although it may look like you can sometimes due to transitive imports; if you do import tornado.httpserver
the tornado.ioloop
package will also be loaded)
Upvotes: 1