当前位置: 首页>>代码示例>>Python>>正文


Python SimpleAsyncHTTPClient.close方法代码示例

本文整理汇总了Python中tornado.simple_httpclient.SimpleAsyncHTTPClient.close方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleAsyncHTTPClient.close方法的具体用法?Python SimpleAsyncHTTPClient.close怎么用?Python SimpleAsyncHTTPClient.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.simple_httpclient.SimpleAsyncHTTPClient的用法示例。


在下文中一共展示了SimpleAsyncHTTPClient.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: raw_fetch

# 需要导入模块: from tornado.simple_httpclient import SimpleAsyncHTTPClient [as 别名]
# 或者: from tornado.simple_httpclient.SimpleAsyncHTTPClient import close [as 别名]
 def raw_fetch(self, headers, body):
     client = SimpleAsyncHTTPClient(self.io_loop)
     conn = RawRequestHTTPConnection(
         self.io_loop, client, httpclient.HTTPRequest(self.get_url("/")), None, self.stop, 1024 * 1024
     )
     conn.set_request(b("\r\n").join(headers + [utf8("Content-Length: %d\r\n" % len(body))]) + b("\r\n") + body)
     response = self.wait()
     client.close()
     response.rethrow()
     return response
开发者ID:trawor,项目名称:tornado,代码行数:12,代码来源:httpserver_test.py

示例2: raw_fetch

# 需要导入模块: from tornado.simple_httpclient import SimpleAsyncHTTPClient [as 别名]
# 或者: from tornado.simple_httpclient.SimpleAsyncHTTPClient import close [as 别名]
 def raw_fetch(self, headers, body):
     client = SimpleAsyncHTTPClient(self.io_loop)
     conn = RawRequestHTTPConnection(
         self.io_loop, client,
         httpclient._RequestProxy(
             httpclient.HTTPRequest(self.get_url("/")),
             dict(httpclient.HTTPRequest._DEFAULTS)),
         None, self.stop,
         1024 * 1024, Resolver(io_loop=self.io_loop))
     conn.set_request(
         b"\r\n".join(headers +
                      [utf8("Content-Length: %d\r\n" % len(body))]) +
         b"\r\n" + body)
     response = self.wait()
     client.close()
     response.rethrow()
     return response
开发者ID:good1111,项目名称:pj-redis,代码行数:19,代码来源:httpserver_test.py

示例3: __init__

# 需要导入模块: from tornado.simple_httpclient import SimpleAsyncHTTPClient [as 别名]
# 或者: from tornado.simple_httpclient.SimpleAsyncHTTPClient import close [as 别名]
class AsyncHandler:
    def __init__(self, link: str, loop: IOLoop = None, timeout: int = 50):
        self.link = link
        self.client = SimpleAsyncHTTPClient(loop)
        self.timeout = timeout
        if loop is None:
            self.loop = IOLoop.current(False)
        else:
            self.loop = loop
        self.header_only = False

    def get_response(self, header_only=False):
        self.header_only = header_only
        # result = self.inner_get_response()
        result = self.loop.run_sync(self.inner_get_response)
        self.client.close()
        return result

    @gen.coroutine
    def inner_get_response(self) -> (int, dict, str):
        method = "GET"
        if self.header_only:
            method = "HEAD"
        try:
            req = HTTPRequest(
                self.link,
                headers=WebRequestCommonHeader.get_html_header(),
                request_timeout=self.timeout,
                follow_redirects=True,
                method=method,
            )
            response = yield self.client.fetch(req)
            # self.client.close()
            return response.code, response.headers, response.body
        except HTTPError as ex:
            result = ex.response
            # self.loop.stop()
            return result.code, None, ""
        except:
            # self.loop.stop()
            return 999, None, ""
        finally:
            pass
开发者ID:paulnaoki,项目名称:DomainFinderSrcUniversal,代码行数:45,代码来源:NonBlockingRequest.py

示例4: test_ip

# 需要导入模块: from tornado.simple_httpclient import SimpleAsyncHTTPClient [as 别名]
# 或者: from tornado.simple_httpclient.SimpleAsyncHTTPClient import close [as 别名]
def test_ip(ip):
    hostname = APP_ID + '.appspot.com'
    url = 'https://' + hostname + '/2'
    request = HTTPRequest(url, request_timeout=5)

    try:
        client = SimpleAsyncHTTPClient(force_instance=True,
                hostname_mapping={hostname: ip})

        res = yield client.fetch(request, raise_error=False)
        if isinstance(res.error, OSError):
            if res.error.errno == errno.EMFILE:
                warning_msg = ("Too many open files. You should increase the"
                        " maximum allowed number of network connections in you"
                        " system or decrease the CONCURRENCY setting.")
                warnings.warn(warning_msg)
        if res.code == 200:
            return True
        else:
            return False
    finally:
        client.close()
开发者ID:kawing-chiu,项目名称:search_google_ip,代码行数:24,代码来源:search_google_ip.py


注:本文中的tornado.simple_httpclient.SimpleAsyncHTTPClient.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。