Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
nggit committed Dec 30, 2024
1 parent 467eccd commit 8f3ad09
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tremolo/lib/http_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ async def _handle_request(self, header):
if not self._waiters['request'].done():
self._waiters['request'].set_result(None)

if self.request is not None:
timer = self.set_handler_timeout(
self.options['app_handler_timeout']
)
timer = self.set_handler_timeout(
self.options['app_handler_timeout']
)

try:
try:
if self.request is not None:
await self.headers_received(response)
finally:
timer.cancel()
finally:
timer.cancel()
except (asyncio.CancelledError, Exception) as exc:
data = None

Expand Down Expand Up @@ -460,9 +460,6 @@ async def _handle_keepalive(self):
self.transport.resume_reading()

def connection_lost(self, _):
self.set_handler_timeout(self.options['app_close_timeout'])
self.globals.connections.discard(self)

while self.tasks:
task = self.tasks.pop()

Expand All @@ -485,3 +482,6 @@ def connection_lost(self, _):
self.context.update(transport=None)
self.request = None
self._header_buf = None

self.set_handler_timeout(self.options['app_close_timeout'])
self.globals.connections.discard(self)

0 comments on commit 8f3ad09

Please sign in to comment.