def step_listener(self, connection, event, fd):
#print('%s(%s, %s)' %
# (inspect.currentframe().f_code.co_name,connection,event_str(event)))
if event & ERRMASK:
raise Exception('INTERNAL ERROR. LISTENER NEVER DIES')
elif event & INMASK:
new = self.accept(connection)
if not new:
# happens if peer hangs up during accept or the control is
# rejecting new connections
return
self.pollable(new.fileno(), new, OUTMASK)
self.accepting.append(new)
# ignore all events for the same file descriptor in the current step
# of the main loop. the OS may reuse descriptors aggressively and so
# the events list may include POLLNVAL for the same descriptor. we
# don't need to handle such a POLLNVAL event because that connection
# is replaced (and GCed) by the call to self.pollable() above.
self.unpend.append(new.fileno())
评论列表
文章目录