Skip to main content

Seamlessly run your Django and TornadIO2 project inside Tornado. Like.A.Boss.

Project description

TornadIO2Go integrates TornadIO2 with your Django project. It allows you to run both your Django project and TornadIO2 app from within the same Tornado server. Or you can just use it as a production-ready runserver substitute.

Installation

The quickest way to install is via pip from within a virtualenv.:

pip install https://github.com/rudeb0t/tornadio2go/archive/master.zip#egg=TornadIO2Go

Alternatively, you can opt to use an “editable” installation:

pip install -e https://github.com/rudeb0t/tornadio2go.git#egg=TornadIO2Go

Quick Start

Add tornadio2go to your INSTALLED_APPS and then run syncdb. This will install the models used by TornadIO2Go. Create your tornadio2.SocketConnection subclass and write your event handlers as usual. Then add the following to your settings.py:

TORNADIO2GO = {
    'SOCKETCONNECTION_CLASS': 'path.to.socketConnectionClass'
}

Then from the command line, start the TornadIO2 server:

python manage.py runtornadio2

This will start the server bound to 127.0.0.1 and listening on port 8000.

Django Settings

All of TornadIO2Go’s settings are found in the Django setting TORNADIO2GO. This is a simple Python dict. Available settings, all of them are optional:

  • SOCKETCONNECTION_CLASS - this should be the complete path to the tornadio2.SocketConnection subclass. If this is not specified, runtornadio2 will run your Django project in a Tornado web server.

  • USER_SETTINGS - this is a dict containing options that should be when creating a new tornadio2.router.TornadioRouter instance. This is only used if you specify SOCKETCONNECTION_CLASS.

  • TORNADO_OPTIONS - this is a dict of all the options that you wish to use for the tornado.httpserver.HTTPServer instance that will be created. See HTTPServer documentation.

  • TORNADO_HANDLERS - this is a list of handlers that you want to be added before the FallbackHandler.

Command Line Options

The runtornadio2 command has similar command line options to Django’s runserver command. Do::

python manage.py runtornadio2 --help

To display a list of available options. Typical usage is::

python manage.py runtornadio2 [options] [optional port number, or ipaddr:port]

To run a multi-process server, use the --num-process option and set it to either zero or any number greater than one. Set to zero to automatically detect the number of available CPU cores and fork the appropriate number of processes. Set to any number greater than one to fork a specific number of processes.

Running With supervisord

In order to run tornadio2go under supervisord you must use the –noreload or –num-process=1 flag in the command parameter for the ini section of your configuration file. supervisord does not like it when its supervised programs do a fork() and the reloader does just that.

Signals

Experimental in 1.0.3

Version 1.0.3 introduces signals which are sent during different stages of initialization. The list of signals (in the order that they are sent) are as follows:

  • pre_server_start

  • post_server_start

  • pre_add_handlers

  • post_add_handlers

The signals handlers will all receive the tornado.web.Application object in the tornado_app keyword argument. Unless otherwise indicated, the sender is always the tornado.httpserver.HTTPServer object.

This feature is currently marked as EXPERIMENTAL and might change in future versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TornadIO2Go-1.0.4.tar.gz (81.4 kB view details)

Uploaded Source

File details

Details for the file TornadIO2Go-1.0.4.tar.gz.

File metadata

  • Download URL: TornadIO2Go-1.0.4.tar.gz
  • Upload date:
  • Size: 81.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for TornadIO2Go-1.0.4.tar.gz
Algorithm Hash digest
SHA256 5045bd5710fa7d4f20e510b040a985f293efa439e90ad107eee9ebcb982ebf35
MD5 7dd89d2e00b4c52f6c3b68705f010adf
BLAKE2b-256 8166b7d84922c5e2577b8545c3a93cdf8d4f87a1ef4a9e95f64bcc29aade160c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page