Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nggit committed Dec 19, 2024
1 parent 8ef7ea9 commit 8c13c06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions tremolo/lib/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@


class KeepAliveConnections(dict):
def __init__(self, *args, maxlen=512, **kwargs):
def __init__(self, maxlen=512):
if not isinstance(maxlen, int) or maxlen < 1:
raise ValueError(
'maxlen must be an integer greater than or equal to 1, '
'got %s' % repr(maxlen)
)

self._maxlen = maxlen
super().__init__(*args, **kwargs)

def __repr__(self):
return self.keys().__repr__()
Expand Down
24 changes: 12 additions & 12 deletions tremolo/tremolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ def __init__(self):
self.loop = None
self.logger = None

def listen(self, port, host=None, **options):
if not isinstance(port, int):
# assume it's a UNIX socket path
host = port
port = None

if (host, port) in self.ports:
return False

self.ports[(host, port)] = options
return (host, port) in self.ports

def route(self, path):
if isinstance(path, int):
return self.error(path)
Expand Down Expand Up @@ -158,6 +146,18 @@ def add_middleware(self, func, name='request', priority=999, kwargs=None):
self.middlewares[name].sort(key=lambda item: item[0],
reverse=name in ('close', 'response'))

def listen(self, port, host=None, **options):
if not isinstance(port, int):
# assume it's a UNIX socket path
host = port
port = None

if (host, port) in self.ports:
return False

self.ports[(host, port)] = options
return (host, port) in self.ports

async def _serve(self, host, port, **options):
backlog = options.get('backlog', 100)

Expand Down

0 comments on commit 8c13c06

Please sign in to comment.