Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bjoern support [do not merge yet] #65

Merged
merged 3 commits into from
Aug 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions chaussette/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
except ImportError:
pass

try:
from chaussette.backend import _bjoern
_backends['bjoern'] = _bjoern.Server
except ImportError:
pass


def register(name, server):
_backends[name] = server
Expand Down
16 changes: 16 additions & 0 deletions chaussette/backend/_bjoern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import socket
from chaussette.util import create_socket
import bjoern


class Server(object):
def __init__(self, listener, application=None, backlog=None,
socket_type=None, address_family=None):
host, port = listener
self.app = application
self.sock = create_socket(host, port, address_family,
socket_type, backlog=backlog)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

def serve_forever(self):
bjoern.server_run(self.sock, self.app)
2 changes: 1 addition & 1 deletion chaussette/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

IS_PYPY = hasattr(sys, 'pypy_version_info')

PY2 = ['eventlet', 'fastgevent', 'gevent',
PY2 = ['bjoern', 'eventlet', 'fastgevent', 'gevent',
'geventwebsocket', 'geventws4py', 'meinheld',
'socketio', 'tornado', 'waitress',
'wsgiref']
Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ list below:
**ws4py** handler.
- **socketio** -- based on gevent-socketio, which is a custom
Gevent server & handler that manages the socketio protocol.
- **bjoern** -- based on Bjoern.


You can select your backend by using the **--backend** option and providing
Expand All @@ -204,6 +205,7 @@ are installed:
- **geventwebsocket**: `pip install gevent-websocket`
- **geventws4py**: `pip install ws4py`
- **socketio**: `pip install gevent-socketio`
- **bjoern**: `pip install bjoern`


If you want to add your favorite WSGI Server as a backend to Chaussette,
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ deps =
gevent-websocket
gevent-socketio
eventlet
bjoern


[testenv:py27]
deps =
Expand All @@ -50,6 +52,7 @@ deps =
gevent-websocket
gevent-socketio
eventlet
bjoern

[testenv:py33]
deps =
Expand Down