0

I am using tornado with django. Right now, my django project structure is like this.

project
--apps
----accounts
----billing
----roles
--settings
----defaults.py
----development.py
----production.py
--__init__.py
--asgi.py
--wsgi.py
--urls.py
--celery.py

manage.py
README.md
LICENSE
requirements.txt
.gitignore

Where would I likely insert all of tornado related code? Ideally, I would be having a module called tornado somewhere with handlers and the application. For development, I would be running tornado via a management command.

Aryan Iyappan
  • 323
  • 1
  • 3
  • 15
  • Keep the Tornado code in a separate folder. And please don't name your module "tornado"; that would cause you some trouble due to the name collision with the actual tornado library. – xyres Apr 28 '21 at 07:07
  • at the root level? @xyres – Aryan Iyappan Apr 28 '21 at 07:08
  • Do you want to run Tornado and Django on separate ports? If so, I'd consider Tornado code a separate project and keep it outside the django project. – xyres Apr 28 '21 at 07:15
  • but I want to use django ORM too, in order to verify users who connect and some more use cases – Aryan Iyappan Apr 28 '21 at 07:23
  • Tornado is asynchronous, so using blocking code (such as Django ORM) would lead to very poor performance. For sharing data between Tornado and Django, you'll need to use some sort of message broker. I've answered a similar question before: https://stackoverflow.com/a/54021901/1925257 – xyres Apr 28 '21 at 07:44
  • Another way is to connect to the database using an async driver (such as [`aiopg`](https://aiopg.readthedocs.io/en/stable/)). You'll have to manually write SQL queries in this case. – xyres Apr 28 '21 at 13:19

0 Answers0