Files
deb-python-eventlet/doc/modules/websocket.rst
Jakub Stasiak 67cde41d03 Improve documentation
This patch:

* exposes eventlet.greenthread.kill function so Sphinx generates
  its documentation and fixes broken links to :func:`kill`
* adds warning about wsgi.server waiting for active connections to
  finish before returning
2014-10-31 09:23:53 +03:00

1.2 KiB

websocket -- Websocket Server

This module provides a simple way to create a websocket server. It works with a few tweaks in the ~eventlet.wsgi module that allow websockets to coexist with other WSGI applications.

To create a websocket server, simply decorate a handler method with WebSocketWSGI and use it as a wsgi application:

from eventlet import wsgi, websocket
import eventlet

@websocket.WebSocketWSGI
def hello_world(ws):
    ws.send("hello world")

wsgi.server(eventlet.listen(('', 8090)), hello_world)

Note

Please see graceful termination warning in ~eventlet.wsgi.server documentation

You can find a slightly more elaborate version of this code in the file examples/websocket.py.

As of version 0.9.13, eventlet.websocket supports SSL websockets; all that's necessary is to use an SSL wsgi server <wsgi_ssl>.

eventlet.websocket