Python HTTPConnectionPOOL错误(Python 2.7)

时间:2018-07-10 09:45:52

标签: python django python-2.7

尝试执行以下操作时得到以下错误:

requests.post('http://xx.xx.xx.xx/url/',data='[{"ModuleCode": "ProductTimeline"}, {"user_id": "90"}]',headers={'Content-type': 'application/json'})

端口和域都打开。

请求版本:请求(2.11.1)
Python版本: 2.7.10

错误:

HTTPConnectionPool(host='IP', port=80): Max retries exceeded with url: /xxx/xx/ (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f1b9247a5d0>: Failed to establish a new connection: [Errno 110] Connection timed out',))
object of type 'NoneType' has no len()
None
Internal Server Error: /xyz/xxxx
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/rest_framework/views.py", line 491, in dispatch
    self.response = self.finalize_response(request, response, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/rest_framework/views.py", line 406, in finalize_response
    % type(response)
AssertionError: Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<type 'NoneType'>`

0 个答案:

没有答案