当我在Python中使用httplib作为我的OAUTH时,我总是得到“CannotSendRequest”然后“ [英] When I use httplib for my OAUTH in Python, I always get "CannotSendRequest" and then "

查看:2150
本文介绍了当我在Python中使用httplib作为我的OAUTH时,我总是得到“CannotSendRequest”然后“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/ea/ea/hell/life/views.py" in linkedin_auth
  274.     token = oauth_linkedin.get_unauthorised_request_token()
File "/home/ea/ea/hell/life/oauth_linkedin.py" in get_unauthorised_request_token
  52.     resp = fetch_response(oauth_request, connection)
File "/home/ea/ea/hell/life/oauth_linkedin.py" in fetch_response
  42.         connection.request(oauth_request.http_method,url)
File "/usr/lib/python2.6/httplib.py" in request
  874.             self._send_request(method, url, body, headers)
File "/usr/lib/python2.6/httplib.py" in _send_request
  891.         self.putrequest(method, url, **skips)
File "/usr/lib/python2.6/httplib.py" in putrequest
  778.             raise CannotSendRequest()

Exception Type: CannotSendRequest at /linkedin/auth
Exception Value: 

然后, BadStatusLine 错误。

And then, sometimes I get: BadStatusLine error instead of this.

这是很随机的。我不知道他们什么时候或为什么发生。 当我运行Django开发服务器时,它会更频繁(当在APACHE2 ...时,不太频繁,但它仍然发生在随机时间)。发生此错误时,必须重新启动我的服务器。

It's pretty random. I don't know when or why they happen. It happens more frequently when I'm running the Django development server (and less frequently when in APACHE2...but it still happens at random times). When this error happens, I have to restart my server.

推荐答案

显然(从这里)如果你尝试重用 httplib.HTTP 尚未完全使用的对象。可能是您正在使用的库中的连接池,以及在请求处理期间抛出的异常?建议是每次都创建新的连接对象。

Apparently (from here) this happens if you try to reuse an httplib.HTTP object which had not been fully used. Maybe a connection pool in the library you're using, and an exception getting thrown during the request processing? Suggestion is to create new connection objects every time.

这篇关于当我在Python中使用httplib作为我的OAUTH时,我总是得到“CannotSendRequest”然后“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆