def _async_sendall(self, data):
        """Internal use only; use 'sendall' with 'yield' instead.

        Asynchronous version of socket sendall method. If socket's
        timeout is set and it expires before all the data could be
        sent, it returns the length of data sent if any data is
        sent. If no data has been sent before timeout, then it causes
        'socket.timeout' exception to be thrown.
        """
        def _sendall(self, data_len):
            try:
                sent = self._rsock.send(self._write_result)
                if sent < 0:
                    self._notifier.clear(self, _AsyncPoller._Write)
                    self._write_task = self._write_result = None
                    coro, self._write_coro = self._write_coro, None
                    coro.throw(*sys.exc_info())
            except ssl.SSLError as err:
                if err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
                    pass
                else:
                    self._notifier.clear(self, _AsyncPoller._Write)
                    self._write_task = self._write_result = None
                    coro, self._write_coro = self._write_coro, None
                    coro.throw(*sys.exc_info())
            except:
                self._notifier.clear(self, _AsyncPoller._Write)
                self._write_task = self._write_result = None
                coro, self._write_coro = self._write_coro, None
                coro.throw(*sys.exc_info())
            else:
                if sent > 0:
                    self._write_result = self._write_result[sent:]
                    if len(self._write_result) == 0:
                        self._notifier.clear(self, _AsyncPoller._Write)
                        self._write_task = self._write_result = None
                        coro, self._write_coro = self._write_coro, None
                        coro._proceed_(None)
                    elif self._timeout:
                        self._notifier._del_timeout(self)
                        self._notifier._add_timeout(self)

        self._write_result = buffer(data)
        self._write_task = functools.partial(_sendall, self, len(data))
        self._write_coro = AsynCoro.cur_coro()
        self._write_coro._await_()
        self._notifier.add(self, _AsyncPoller._Write)
dataset/ETHPy150Open pgiri/asyncoro/py2/asyncoro/__init__.py/_AsyncSocket._async_sendall/original