Skip to content

Instantly share code, notes, and snippets.

View websocket.py
# Author: Jacob Kristhammar, 2010
#
# Updated version of websocket.py[1] that implements latest[2] stable version
# of the websocket protocol.
#
# NB. It's no longer possible to manually select which callback that should
# be invoked upon message reception. Instead you must override the
# on_message(message) method to handle incoming messsages.
# This also means that you don't have to explicitly invoke
# receive_message, in fact you shouldn't.
View polling_example.py
import logging
import random
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
View server.py
import time
import logging
import functools
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
View client.py
import logging
import tornado.ioloop
import tornado.httpclient
import tornado.options
url = "127.0.0.1:8888"
def first():
def handle_response(response):