def __init__(self, loop, url, mode=3, api_key=None, **kwargs):
        loop = loop
        self.api_key = api_key

        # initialize the capabilities
        self.mode = mode
        self.readable = False
        self.writable = False
        if mode & pyuv.UV_READABLE:
            self.readable = True

        if mode & pyuv.UV_WRITABLE:
            self.writable = True

        # set heartbeat
        try:
            self.heartbeat_timeout = kwargs.pop('heartbeat')
        except __HOLE__:
            self.heartbeat_timeout = 15.0
        self._heartbeat = pyuv.Timer(loop)

        # pending messages queue
        self._queue = deque()
        self.pending = {}

        # define status
        self.active = False
        self.closed = False

        # read callback
        self._read_callback = None

        super(IOChannel, self).__init__(loop, url, **kwargs)

        # make sure we authenticate first
        if self.api_key is not None:
            msg = Message("AUTH:%s" % self.api_key)
            self.write_message(msg.encode())
dataset/ETHPy150Open benoitc/gaffer/gaffer/httpclient/websocket.py/IOChannel.__init__