Skip to content

Commit

Permalink
initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekziade committed Aug 10, 2014
1 parent b523b9f commit 1aa57dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions chaussette/backend/__bjoern.py
@@ -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)
7 changes: 7 additions & 0 deletions chaussette/backend/__init__.py
Expand Up @@ -23,6 +23,13 @@
pass


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


PY3 = sys.version_info[0] == 3

if not PY3:
Expand Down

0 comments on commit 1aa57dd

Please sign in to comment.