This website uses cookies and similar technologies to understand visitors' experiences. By continuing to use this website, you accept our use of cookies and similar technologies,Terms of Use, and Privacy Policy.

Sep 17 2011 - 09:15 AM
PyGotham Session 1 - Real time notifications
Doing the real time notifications the python way : PYTHON SIDE Gevent Servers: import gevent.monkey gevent.monkey.patch_all() urllib def server: Gevent: Servers def handle(socket, address): print 'new connection!' server = StreamServer(('',1234), handle) gevent.wsgi (Fast ~4k requests/s) No streaming, pipelining or ssl gevent.pywsgi: Full Featured slower("only" 3k requests/s) from gevent import pywsgi def hello_world(enc, start_response) start_response('200 OK',[('continent-type','text/html')]) yield ' Hello World' server = pywsgi.WSGIServer(''',8080), hello_world) server.serve_forever() a heartbeat loop HOW DO YOU GET THE DATA TO THE CLIENT WITHOUT PAGE REFRESH What is the real time web - No page refreshes - Sevrer push - Examples: chat, realtime analytics, ... Imlementation: a) Flash b) Polling c) Long polling (wow - thats cleevr: ) d) HTML5 Websockets(super-easy, Security Vulnerabilities) Socket.IO To the rescue - Socket.IO aims to make realtime apps possible .
|By: Pranav Garg|2424 Reads