Commit 9fdd750f authored by Julien Muchembled's avatar Julien Muchembled

Simplify cleanup of HandlerSwitcher when closing a connection

This frees a reference to the last handler and there's no need to make the
instance reusable.
parent aaf2251e
...@@ -40,24 +40,19 @@ def not_closed(func): ...@@ -40,24 +40,19 @@ def not_closed(func):
class HandlerSwitcher(object): class HandlerSwitcher(object):
_is_handling = False
_next_timeout = None _next_timeout = None
_next_timeout_msg_id = None _next_timeout_msg_id = None
_next_on_timeout = None _next_on_timeout = None
_pending = ({}, None),
def __init__(self, handler): def __init__(self, handler):
# pending handlers and related requests # pending handlers and related requests
self._pending = [] self._pending = []
self._is_handling = False
self.setHandler(handler) self.setHandler(handler)
def clear(self): def close(self):
self.__init__(self.getLastHandler()) self.__dict__.clear()
try:
del (self._next_timeout,
self._next_timeout_msg_id,
self._next_on_timeout)
except AttributeError:
pass
def isPending(self): def isPending(self):
return bool(self._pending[0][0]) return bool(self._pending[0][0])
...@@ -530,7 +525,7 @@ class Connection(BaseConnection): ...@@ -530,7 +525,7 @@ class Connection(BaseConnection):
else: else:
handler.connectionClosed(self) handler.connectionClosed(self)
finally: finally:
self._handlers.clear() self._handlers.close()
def _closure(self): def _closure(self):
assert self.connector is not None, self.whoSetConnector() assert self.connector is not None, self.whoSetConnector()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment