如何从GAE Python的开发服务器(dev_appserver.py)提供电影文件?

Chi*_*ato 5 python google-app-engine

我想在GAE python开发环境中使用mp4/video(使用dev_appserver.py),但到目前为止我无法在浏览器上播放它.

由于"Broken Pipe"错误发生在开发服务器上,并且我能够在生产环境(在谷歌的服务器上)上播放,因此问题可能是由浏览器的并行请求引起的.(如果我的理解是正确的,dev_appserver.py是单线程的,无法处理并行请求.)

我尝试过Chrome的"--disable-preconnect"选项,但它没有解决问题.

它有什么变通方法吗?非常感谢您的建议.

编辑:电影文件存储为静态资源,我试图直接访问它(没有使用视频标签).

[版本信息]

  • 操作系统:Ubuntu 12.04 LTE
  • 浏览器:Chrome 19.0.1084.46,Firefox 12.0
  • GAE:Python - 1.6.5,
  • Python:2.7.3

[错误日志]

    INFO     2012-05-21 07:35:04,575 dev_appserver.py:2891] "GET /static/test.mp4 HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 36240)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/chikashi/Development/google_appengine/google/appengine/tools/dev_appserver.py", line 2579, in __init__
    BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__
    self.finish()
  File "/usr/lib/python2.7/SocketServer.py", line 693, in finish
    self.wfile.flush()
  File "/usr/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------
Run Code Online (Sandbox Code Playgroud)

rba*_*ffy 1

任何非常长的操作(例如提供电影)都会占用一个线程,直到它完成。由于开发服务器是单线程的,因此其唯一的工作线程必须等到下载完成才能处理下一个请求。

无论如何,生产 App Engine 环境不会出现此问题,并且只要文件不是太大(我不记得限制),它就会很乐意为您提供服务。

您还可以考虑从另一台服务器提供电影文件。根据您使用的带宽,有比 App Engine 更便宜的托管解决方案(即使没有一个像他们的那样酷;-))