websocket.py 文件源码

python
阅读 51 收藏 0 点赞 0 评论 0

项目:wptagent 作者: WPO-Foundation 项目源码 文件源码
def close(self, code=1000, reason=''):
        """
        Call this method to initiate the websocket connection
        closing by sending a close frame to the connected peer.
        The ``code`` is the status code representing the
        termination's reason.

        Once this method is called, the ``server_terminated``
        attribute is set. Calling this method several times is
        safe as the closing frame will be sent only the first
        time.

        .. seealso:: Defined Status Codes http://tools.ietf.org/html/rfc6455#section-7.4.1
        """
        if not self.server_terminated:
            self.server_terminated = True
            try:
                self._write(self.stream.close(code=code, reason=reason).single(mask=self.stream.always_mask))
            except Exception as ex:
                logger.error("Error when terminating the connection: %s", str(ex))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号