'Manage the bitmask for reading/writing/error which is used by the
io/event handler to specify when there is an event such as a read or
write.'

def _manage_event_state(self):

    if self.outbound_buffer:
        if (not (self.event_state & self.WRITE)):
            self.event_state |= self.WRITE
            self.ioloop.update_handler(self.socket.fileno(), self.event_state)
    elif (self.event_state & self.WRITE):
        self.event_state = self.base_events
        self.ioloop.update_handler(self.socket.fileno(), self.event_state)
