session.py 文件源码

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

项目:dataplicity-lomond 作者: wildfoundry 项目源码 文件源码
def _close_socket(self):
        """Close the socket safely."""
        # Is a no-op if the socket is already closed.
        if self._sock is None:
            return
        try:
            # Get the write lock, so we can be certain data sending
            # in another thread is sent.
            with self._lock:
                self._sock.shutdown(socket.SHUT_RDWR)
                self._sock.close()
        except socket.error:
            # Socket is already closed.
            # That's fine, just a no-op.
            pass
        except Exception as error:
            # Paranoia
            log.warning('error closing socket (%s)', error)
        finally:
            self._sock = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号