Skip to content

Commit

Permalink
Add processed connection stat counter
Browse files Browse the repository at this point in the history
  • Loading branch information
belyalov committed Nov 18, 2018
1 parent 4e3137e commit 9111329
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tinyweb/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ def __init__(self, request_timeout=3, max_concurrency=3, backlog=16, debug=False
self.parameterized_url_map = {}
# Currently opened connections
self.conns = {}
# Statistics
self.processed_connections = 0

def _find_url_handler(self, req):
"""Helper to find URL handler.
Expand Down Expand Up @@ -593,6 +595,7 @@ async def _tcp_server(self, host, port, backlog):
csock.setblocking(False)
# Start handler / keep it in the map - to be able to
# shutdown gracefully - by close all connections
self.processed_connections += 1
hid = id(csock)
handler = self._handler(asyncio.StreamReader(csock),
asyncio.StreamWriter(csock, {}))
Expand Down

0 comments on commit 9111329

Please sign in to comment.