Commit 4a0b936f authored by Julien Muchembled's avatar Julien Muchembled

Indent many lines before any real change

This is a preliminary commit, without any functional change,
just to make the next one easier to review.
parent 9f4dd15e
...@@ -49,8 +49,8 @@ class EpollEventManager(object): ...@@ -49,8 +49,8 @@ class EpollEventManager(object):
def getConnectionList(self): def getConnectionList(self):
# XXX: use index # XXX: use index
return [x for x in self.connection_dict.itervalues() return [x for x in self.connection_dict.itervalues()
if not x.isAborted()] if not x.isAborted()]
def getClientList(self): def getClientList(self):
# XXX: use index # XXX: use index
...@@ -135,13 +135,14 @@ class EpollEventManager(object): ...@@ -135,13 +135,14 @@ class EpollEventManager(object):
def _poll(self, blocking): def _poll(self, blocking):
if blocking: if blocking:
timeout = self._timeout if 1:
timeout_object = self timeout = self._timeout
for conn in self.connection_dict.itervalues(): timeout_object = self
t = conn.getTimeout() for conn in self.connection_dict.itervalues():
if t and (timeout is None or t < timeout): t = conn.getTimeout()
timeout = t if t and (timeout is None or t < timeout):
timeout_object = conn timeout = t
timeout_object = conn
# Make sure epoll_wait does not return too early, because it has a # Make sure epoll_wait does not return too early, because it has a
# granularity of 1ms and Python 2.7 rounds the timeout towards zero. # granularity of 1ms and Python 2.7 rounds the timeout towards zero.
# See also https://bugs.python.org/issue20452 (fixed in Python 3). # See also https://bugs.python.org/issue20452 (fixed in Python 3).
...@@ -155,38 +156,40 @@ class EpollEventManager(object): ...@@ -155,38 +156,40 @@ class EpollEventManager(object):
elif exc.errno != EINTR: elif exc.errno != EINTR:
raise raise
return return
if event_list: else:
self.unregistered = unregistered = [] if event_list:
wlist = [] self.unregistered = unregistered = []
elist = [] wlist = []
for fd, event in event_list: elist = []
if event & EPOLLIN: for fd, event in event_list:
conn = self.connection_dict[fd] if event & EPOLLIN:
conn = self.connection_dict[fd]
if conn.readable():
self._addPendingConnection(conn)
if event & EPOLLOUT:
wlist.append(fd)
if event & (EPOLLERR | EPOLLHUP):
elist.append(fd)
for fd in wlist:
if fd not in unregistered:
self.connection_dict[fd].writable()
for fd in elist:
if fd in unregistered:
continue
try:
conn = self.connection_dict[fd]
except KeyError:
assert fd == self._trigger_fd, fd
with self._trigger_lock:
self.epoll.unregister(fd)
if self._trigger_exit:
del self._trigger_exit
thread.exit()
continue
if conn.readable(): if conn.readable():
self._addPendingConnection(conn) self._addPendingConnection(conn)
if event & EPOLLOUT: return
wlist.append(fd) if blocking > 0:
if event & (EPOLLERR | EPOLLHUP):
elist.append(fd)
for fd in wlist:
if fd not in unregistered:
self.connection_dict[fd].writable()
for fd in elist:
if fd in unregistered:
continue
try:
conn = self.connection_dict[fd]
except KeyError:
assert fd == self._trigger_fd, fd
with self._trigger_lock:
self.epoll.unregister(fd)
if self._trigger_exit:
del self._trigger_exit
thread.exit()
continue
if conn.readable():
self._addPendingConnection(conn)
elif blocking > 0:
logging.debug('timeout triggered for %r', timeout_object) logging.debug('timeout triggered for %r', timeout_object)
timeout_object.onTimeout() timeout_object.onTimeout()
......
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