Python:TypeError的HTTP请求:需要一个整数(Get-type套接字)

Python:TypeError的HTTP请求:需要一个整数(Get-type套接字),python,django,unit-testing,http,request,Python,Django,Unit Testing,Http,Request,在试图通过HTTP检索资源时,我遇到了一个非常奇怪的错误。这似乎发生在任何HTTP客户机上(尝试过的请求和具有相同结果的urllib) 我的项目使用django,我使用tox和标准django命令python manage.py test运行测试。当我运行我的测试套件,单元测试发出HTTP请求时(例如通过requests.get()http://example.com“)),测试失败并出现错误,测试套件将一直持续到结束,并挂起。我必须通过命令行手动终止进程 经过一些调查,我在http请求周围放置

在试图通过HTTP检索资源时,我遇到了一个非常奇怪的错误。这似乎发生在任何HTTP客户机上(尝试过的请求和具有相同结果的urllib)

我的项目使用django,我使用tox和标准django命令
python manage.py test
运行测试。当我运行我的测试套件,单元测试发出HTTP请求时(例如通过
requests.get()http://example.com“)
),测试失败并出现错误,测试套件将一直持续到结束,并挂起。我必须通过命令行手动终止进程

经过一些调查,我在http请求周围放置了一个
try/except
块,并得到以下堆栈跟踪:

File "/mycomputer/python3.4/site-packages/requests/api.py", line 68, in get
  return request('get', url, **kwargs)
File "/mycomputer/python3.4/site-packages/requests/api.py", line 50, in request
  response = session.request(method=method, url=url, **kwargs)
File "/mycomputer/python3.4/site-packages/requests/sessions.py", line 464, in request
  resp = self.send(prep, **send_kwargs)
File "/mycomputer/python3.4/site-packages/requests/sessions.py", line 576, in send
  r = adapter.send(request, **kwargs)
File "/mycomputer/python3.4/site-packages/requests/adapters.py", line 370, in send
  timeout=timeout
File "/mycomputer/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
  body=body, headers=headers)
File "/mycomputer/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 349, in _make_request
  conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.4/http/client.py", line 1065, in request
  self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1103, in _send_request
  self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1061, in endheaders
  self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 906, in _send_output
  self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 841, in send
  self.connect()
File "/mycomputer/python3.4/site-packages/requests/packages/urllib3/connection.py", line 155, in connect
  conn = self._new_conn()
File "/mycomputer/python3.4/site-packages/requests/packages/urllib3/connection.py", line 134, in _new_conn
  (self.host, self.port), self.timeout, **extra_kw)
File "/mycomputer/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 68, in create_connection
  sock = socket.socket(af, socktype, proto)
File "/usr/lib/python3.4/socket.py", line 123, in __init__
  _socket.socket.__init__(self, family, type, proto, fileno)
TypeError: an integer is required (got type socket)
我真的不明白这里的问题。从命令行运行同样的东西效果很好,所以这可能与我的项目架构有关。同样,在另一台计算机上运行测试套件也会以同样的方式失败


有人遇到过类似的问题吗?我能做些什么来追踪问题?

我在某个地方读到,django不是一个完整的服务器,当您尝试将其作为一个服务器使用时,可能会导致问题。也许这就是其中之一


你试过了吗?

好的,问题是由我用来嘲笑的第三方软件包引起的。

如果我不清楚,很抱歉:我没有针对我自己的网站进行请求。所有请求都是针对第三方API完成的。所以我认为它与django的内置Web服务器无关。