bdarnell / django-tornado-demo Goto Github PK
View Code? Open in Web Editor NEWDemo app for django and tornado in one process
Demo app for django and tornado in one process
This relates to tornado_main.py. http://localhost:8080/hello-tornado works OK but
http://localhost:8080/hello-django returns a 500: Internal Server Error
Hello,
def main():
tornado.options.parse_command_line()
wsgi_app = tornado.wsgi.WSGIContainer(
django.core.handlers.wsgi.WSGIHandler())
application = Application([(r'/websocket/', planet_socket.WsDate),
('.*', FallbackHandler, dict(fallback=wsgi_app)),
],
**settings)
print options.port
server = tornado.httpserver.HTTPServer(application)
server.listen(options.port)
tornado.ioloop.IOLoop.current().start()
if __name__ == '__main__':
main()
When we are running the project as above, We take the problems as below.
When a request starts(such as showing 10K records to the screen) all other requests are waiting until the first request is completed.
Requests which are running on Web Socket are waiting for first request's completion.
When a user starts the first request then all other users are waiting the first request's completion.
Sample Project is here. How Can We fix this problems..
Do you have any idea ?
Thanks...
Hi, is there any way to run this (tornado_main.py) along with django builtin webserver, not just inside wsgi app, please?
this example is created 4 years ago and dont working now please refresh.
This demo is simple and useful, but because of the issue, --port=XXXX won't be effective.
Hi bdarnell,
It is very usefull repo for me. I am runing tornado server and it is working fine, But when I am using gunicorn i'm facing some issues. Can you please look at this error,
Traceback (most recent call last):
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
worker.init_process()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
self.wsgi = self.app.wsgi()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
import(module)
File "/home/dhana/webrtc/neonarc2/tornado_server.py", line 10, in
from rtc import render_view
File "/home/dhana/webrtc/neonarc2/rtc/init.py", line 7, in
django.setup()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/init.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/dhana/webrtc/neonarc2/user_management/models.py", line 3, in
from allauth.account.models import EmailAddress
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/allauth/account/models.py", line 20, in
from .managers import EmailAddressManager, EmailConfirmationManager
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/allauth/account/managers.py", line 57, in
class EmailConfirmationManager(models.Manager):
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/utils/deprecation.py", line 58, in new
wrapper = warn_about_renamed_method(class_name, *renamed_method)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/workers/gtornado.py", line 36, in handle_exit
self.stop()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/workers/gtornado.py", line 117, in stop
PeriodicCallback(self.stop_ioloop, 1000, io_loop=self.ioloop).start()
AttributeError: 'TornadoWorker' object has no attribute 'ioloop'
Traceback (most recent call last):
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
worker.init_process()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
self.wsgi = self.app.wsgi()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
import(module)
File "/home/dhana/webrtc/neonarc2/tornado_server.py", line 10, in
from rtc import render_view
File "/home/dhana/webrtc/neonarc2/rtc/init.py", line 7, in
django.setup()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/init.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/dhana/webrtc/neonarc2/user_management/models.py", line 3, in
from allauth.account.models import EmailAddress
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/allauth/account/models.py", line 20, in
from .managers import EmailAddressManager, EmailConfirmationManager
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/allauth/account/managers.py", line 57, in
class EmailConfirmationManager(models.Manager):
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/django/utils/deprecation.py", line 58, in new
wrapper = warn_about_renamed_method(class_name, *renamed_method)
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/workers/gtornado.py", line 36, in handle_exit
self.stop()
File "/home/dhana/webrtc/env/local/lib/python2.7/site-packages/gunicorn/workers/gtornado.py", line 117, in stop
PeriodicCallback(self.stop_ioloop, 1000, io_loop=self.ioloop).start()
AttributeError: 'TornadoWorker' object has no attribute 'ioloop'
[2015-03-15 11:41:34 +0000] [9697] [INFO] Worker exiting (pid: 9697)
Have you checked in django 1.6?
Not working..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.