hacking.py 文件源码

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

项目:stepler 作者: Mirantis 项目源码 文件源码
def settimeout():
    """Function to return wrapper over ``socket.socket.set_timeout``."""
    def wrapper(self, timeout):
        """Wrapper to prevent ability change default socket timeout to None.

        Note:
            This is workaround for https://github.com/kennethreitz/requests/blob/5524472cc76ea00d64181505f1fbb7f93f11cc2b/requests/packages/urllib3/connectionpool.py#L381  # noqa

        Args:
            timeout (int): Seconds of socket timeout.
        """
        if self.gettimeout() and timeout is None:
            return
        settimeout_func(self, timeout)

    settimeout_func = six.get_unbound_function(socket.socket.settimeout)
    wrapper.__doc__ = settimeout_func.__doc__
    wrapper.__name__ = settimeout_func.__name__
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号