本文介绍了截止日期超过多张卡片发布到附带视频的时间线上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我使用python over gae,并试图将带有视频附件的卡片推送到访问我玻璃器皿的所有用户。
这是代码:

  #posting video 
media_link = util.get_full_url(self,'/静态/视频/ man_on_the_moon.mp4')
resp = urlfetch.fetch(media_link,deadline = 2000)
media_video = MediaIoBaseUpload(io.BytesIO(resp.content),mimetype ='video / vnd.google -glass.stream-url',
resumable = True)

users = Credentials.all()
用户用户:
creds = StorageByKeyName(凭证, user.key()。name(),'credentials')。get()
mirror_service = util.create_service('mirror','v1',creds)
timeline_item = {'text':'视频模式v3'​​}
mirror_service.timeline()。insert(body = timeline_item,media_body = media_video).execute()

在我的本地机器上,这段代码工作正常,但是在gae上部署它会产生这样的结果:

 : HTT PException:等待来自URL的HTTP响应时超出了截止时间:https://www.googleapis.com/upload/mirror/v1/timeline?uploadType=resumable&alt=json&upload_id=AEnB2UqeMjtTAaB7wWw-8yuVoaBdxaD5-mkFx2TJo7PynEXmVCkPLlDFo0l_1t8du_JetszdgmHXF9d-VuD8N0XmwXQVBMynow 

有关如何解决此问题的任何想法?
据我了解时间表()。插入上传media_body每个用户我张贴卡。这在我看来非常耗费资源。对吗?


再次感谢你们

这是完整的堆叠:

 在等待来自网址的HTTP响应时超出了截止日期:https://www.googleapis.com/upload/mirror/v1/timeline?uploadType=multipart&alt=json 
Traceback(最近一次调用最后):
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,行1511,在__call__
rv = self.handle_exception(request,response,e)
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1505行,在__call__
中rv = self.router.dispatch(request,response)
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1253行,在default_dispatcher
中返回route.handler_adapter(request,response)
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1077行,在__call__
返回handler.dispatch()
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第547行,发送
返回self.handle_exception(e,self.app.debug)
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第545行,发送
返回方法(* args,** kwargs)
文件/base/data/home/apps/s~watchup-stage/1.369179617747477845/main_handler.py,行340,在
后mirror_service.timeline()。insert(body = timeline_item,media_body = media_video).execute()
文件lib / oauth2client / util.py,位于位置wrapper的第128行
return wrapped(* args, ** kwargs)
执行
body = self.body,headers = self.headers)
文件lib / apiclient / http.py,行676,文件lib / oauth2client / util.py,第128行,位于位置包装程序
中返回包装(* args,** kwargs)
在new_request中包含文件lib / oauth2client / client.py490行$ b $ redi (请求,内容)= self._request(conn,authority,uri,request_uri,method,body,rections,connection_type)
文件lib / httplib2 / __ init__.py,行1570,请求
头文件,重定向,cachekey)
在_request
(response,content)= self._conn_request(conn,request_uri,method,body,headers)文件lib / httplib2 / __ init__.py,第1317行,
在_conn_request
response = conn.getresponse()
文件/ base / data / home / runtimes / python27 / python27_dist / lib / python2.7 / httplib.py,第500行,在getresponse中
raise HTTPException(str(e))
HTTPException:在等待来自URL:http:// www的HTTP响应时超出了截止时间。 googleapis.com/upload/mirror/v1/timeline?uploadType=multipart&alt=json


解决方案

我也遇到过这类问题。为了解决这个问题,我不得不增加HTTP请求的超时以及移动到队列。



我向Google Mirror API Python示例提交了一个pull请求,但它被拒绝让事情变得简单。



你可以在。



基本上,简介是:


  1. 将处理移至队列

  2. 导入urlfetch并httplib2

  3. 增加urlfetch和httplib2的超时时间,如下所示:

      urlfetch .set_default_fetch_deadline(45)
    httplib2.Http(timeout = 45)


随着这些变化,我不会再有超时。


first of all i'm using python over gae and i'm trying to push a card with a video attachment to all the users that visited my glassware.This is the code:

        #posting video
        media_link = util.get_full_url(self, '/static/video/man_on_the_moon.mp4')
        resp = urlfetch.fetch(media_link, deadline=2000)
        media_video = MediaIoBaseUpload(io.BytesIO(resp.content), mimetype='video/vnd.google-glass.stream-url',
                                            resumable=True)

        users = Credentials.all()
        for user in users:
            creds = StorageByKeyName(Credentials, user.key().name(), 'credentials').get()
            mirror_service = util.create_service('mirror', 'v1', creds)
            timeline_item = {'text': 'video mode v3'}
            mirror_service.timeline().insert(body=timeline_item, media_body=media_video).execute()

On my local machine this code is working flawless but deploying it on gae generates this:

: HTTPException: Deadline exceeded while waiting for HTTP response from URL: https://www.googleapis.com/upload/mirror/v1/timeline?uploadType=resumable&alt=json&upload_id=AEnB2UqeMjtTAaB7wWw-8yuVoaBdxaD5-mkFx2TJo7PynEXmVCkPLlDFo0l_1t8du_JetszdgmHXF9d-VuD8N0XmwXQVBMynow

Any idea on how to solve this?As far as i understood the timeline().insert uploads the media_body each and every time for each user i post the card to. This seems to me quite resource consuming. Right?

Thanks again guys

this is the full stack:

    Deadline exceeded while waiting for HTTP response from URL: https://www.googleapis.com/upload/mirror/v1/timeline?uploadType=multipart&alt=json
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~watchup-stage/1.369179617747477845/main_handler.py", line 340, in post
    mirror_service.timeline().insert(body=timeline_item, media_body=media_video).execute()
  File "lib/oauth2client/util.py", line 128, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "lib/apiclient/http.py", line 676, in execute
    body=self.body, headers=self.headers)
  File "lib/oauth2client/util.py", line 128, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "lib/oauth2client/client.py", line 490, in new_request
    redirections, connection_type)
  File "lib/httplib2/__init__.py", line 1570, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "lib/httplib2/__init__.py", line 1317, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "lib/httplib2/__init__.py", line 1286, in _conn_request
    response = conn.getresponse()
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/httplib.py", line 500, in getresponse
    raise HTTPException(str(e))
HTTPException: Deadline exceeded while waiting for HTTP response from URL: https://www.googleapis.com/upload/mirror/v1/timeline?uploadType=multipart&alt=json
解决方案

I too was experiencing this type of issue. In order to solve it, I had to increase the timeout for HTTP requests as well as move to a Queue.

I submitted a pull request to the Google Mirror API Python example, but it got rejected to keep things "simple".

You can checkout my diff at https://github.com/JessieAMorris/mirror-quickstart-python/commit/b67c0ecdf83207b0c3b596173c95a53804b23525.

Basically, the synopsis is:

  1. Move processing to a queue
  2. import urlfetch and httplib2
  3. Increase the timeouts for urlfetch and httplib2 like so:

    urlfetch.set_default_fetch_deadline(45)
    httplib2.Http(timeout=45) 
    

With those changes in place, I don't get timeouts any more.

这篇关于截止日期超过多张卡片发布到附带视频的时间线上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 12:29