Skip to content

Commit

Permalink
Merge pull request #65 from mozilla-services/bjoern
Browse files Browse the repository at this point in the history
Bjoern support
  • Loading branch information
tarekziade committed Aug 12, 2014
2 parents f33370a + 2467faa commit 213d313
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
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

0 comments on commit 213d313

Please sign in to comment.