sinacloud / sae-python-dev-guide

SAE Python开发者手册
http://sae.sina.com.cn/doc/python
462 stars 353 forks source link

请求https网站报错 #143

Closed awong1900 closed 8 years ago

awong1900 commented 8 years ago

Hi sae team

import tornado.web
import urllib
from tornado.httpclient import AsyncHTTPClient

class MainHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def get(self):
        http = tornado.httpclient.AsyncHTTPClient()
        http.fetch("http://zuqiuxunlian.com", callback=self._callback)
        self.write("Hello to the Tornado world! ")
        self.flush()

    def _callback(self, response):
        self.write(response.body)
        self.finish()

class TempHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def get(self):
        http = tornado.httpclient.AsyncHTTPClient()
        http.fetch("https://www.baidu.com", callback=self._callback)
        self.write("Hello to the Tornado world! ")
        self.flush()

    def _callback(self, response):
        self.write(response.body)
        self.finish()

settings = {
    "debug": True,
}

# application should be an instance of `tornado.web.Application`,
# and don't wrap it with `sae.create_wsgi_app`
application = tornado.web.Application([
    (r"/", MainHandler),
    (r"/temp", TempHandler),
], **settings)

第一个http响应正常。 第二https请求不到。 错误如下:

  - [2016/01/03 20:22:06] - WARNING:root:uncaught exception
Traceback (most recent call last):
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/simple_httpclient.py", line 289, in cleanup
    yield
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/stack_context.py", line 183, in wrapped
    callback(*args, **kwargs)
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/simple_httpclient.py", line 300, in _on_close
    error=HTTPError(599, "Connection closed")))
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/simple_httpclient.py", line 284, in _run_callback
    final_callback(response)
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/stack_context.py", line 180, in wrapped
    callback(*args, **kwargs)
  File "/usr/local/sae/python/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/stack_context.py", line 216, in _nested
    if exit(*exc):
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/stack_context.py", line 124, in __exit__
    return self.exception_handler(type, value, traceback)
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/web.py", line 935, in _stack_context_handle_exception
    self._handle_request_exception(value)
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/web.py", line 998, in _handle_request_exception
    self.send_error(500, exc_info=sys.exc_info())
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/web.py", line 659, in send_error
    self.finish()
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/web.py", line 640, in finish
    self.flush(include_footers=True)
  File "/usr/local/sae/python/lib/python2.7/site-packages/tornado/web.py", line 584, in flush
    chunk = b("").join(self._write_buffer)
TypeError: sequence item 0: expected string, NoneType found  yq26 

如果能帮忙定位错误,不甚感激。

chanfung032 commented 8 years ago

你好,sae的python runtime对tornado worker支持不是非常完善,建议使用云容器的python环境,具体可以见: https://github.com/sinacloud/python-getting-started ,这个对tornado等提供了原生的支持,目前还在开发中,不久就会对外推出。

awong1900 commented 8 years ago

好的。 网站上目前只开放了GO和node.js。等待你们的更新...

在 2016年1月4日 下午3:04,Alan Chan notifications@github.com写道:

你好,sae的python runtime对tornado worker支持不是非常完善,建议使用云容器的python环境,具体可以见: https://github.com/sinacloud/python-getting-started ,这个对tornado等提供了原生的支持,目前还在开发中,不久就会对外推出。

— Reply to this email directly or view it on GitHub https://github.com/sinacloud/sae-python-dev-guide/issues/143#issuecomment-168599059 .

chanfung032 commented 8 years ago

你好,云容器创建的应用是和语言无关的,只是目前优先提供Go和NodeJS的支持,直接创建就可以部署Python应用了。

awong1900 commented 8 years ago

没有相关文档。不会弄。

2016-01-05 13:49 GMT+08:00 Alan Chan notifications@github.com:

你好,云容器创建的应用是和语言无关的,只是目前优先提供Go和NodeJS的支持,直接创建就可以部署Python应用了。

— Reply to this email directly or view it on GitHub https://github.com/sinacloud/sae-python-dev-guide/issues/143#issuecomment-168905932 .