Python Google云数据存储模拟器在测试套件中途拒绝基于HTTP的重置请求

Python Google云数据存储模拟器在测试套件中途拒绝基于HTTP的重置请求,python,google-app-engine,google-cloud-datastore,python-unittest,google-app-engine-python,Python,Google App Engine,Google Cloud Datastore,Python Unittest,Google App Engine Python,我正在将Python2应用程序引擎应用程序从NDB迁移到Cloud NDB,作为迁移到Python3的先驱。根据其他地方的建议,我已经用本地数据存储模拟器取代了我对测试床的使用,并且在很大程度上已经实现了。我遇到的是一个错误,它在我们的测试套件中580个单元测试的中途突然出现。错误消息似乎表明仿真器无法跟上来自test setUp()方法的rapidfire重置请求 我的所有测试都使用以下setUp()方法从基类派生: 我正在终端窗口中使用以下命令运行云数据存储: $ gcloud beta e

我正在将Python2应用程序引擎应用程序从NDB迁移到Cloud NDB,作为迁移到Python3的先驱。根据其他地方的建议,我已经用本地数据存储模拟器取代了我对测试床的使用,并且在很大程度上已经实现了。我遇到的是一个错误,它在我们的测试套件中580个单元测试的中途突然出现。错误消息似乎表明仿真器无法跟上来自test setUp()方法的rapidfire重置请求

我的所有测试都使用以下setUp()方法从基类派生:

我正在终端窗口中使用以下命令运行云数据存储:

$ gcloud beta emulators datastore start --no-store-on-disk --consistency=1.0 --host-port=localhost:8089
在测试套件进行到一半时,测试开始失败,出现以下错误:

ERROR: test_a_thing (my_test.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/my_test.py", line 11, in setUp
  File "/Users/myuser/Projects/MyProject/test/_base_test.py", line 29, in setUp
  File "/Users/myuser/Projects/MyProject/lib/requests/api.py", line 119, in post
  File "/Users/myuser/Projects/MyProject/lib/requests/api.py", line 61, in request
  File "/Users/myuser/Projects/MyProject/lib/requests/sessions.py", line 530, in request
  File "/Users/myuser/Projects/MyProject/lib/requests/sessions.py", line 643, in send
  File "/Users/myuser/Projects/MyProject/lib/requests/adapters.py", line 516, in send
ConnectionError: HTTPConnectionPool(host='localhost', port=8089): Max retries exceeded with url: /reset (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x113715610>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
错误:测试一个东西(my\u test.test)
----------------------------------------------------------------------
回溯(最近一次呼叫最后一次):
设置中第11行的文件“test/my_test.py”
文件“/Users/myuser/Projects/MyProject/test/\u base\u test.py”,第29行,在安装程序中
文件“/Users/myuser/Projects/MyProject/lib/requests/api.py”,第119行,在post中
文件“/Users/myuser/Projects/MyProject/lib/requests/api.py”,请求中的第61行
文件“/Users/myuser/Projects/MyProject/lib/requests/sessions.py”,请求中的第530行
文件“/Users/myuser/Projects/MyProject/lib/requests/sessions.py”,第643行,在send中
文件“/Users/myuser/Projects/MyProject/lib/requests/adapters.py”,第516行,在send中
ConnectionError:HTTPConnectionPool(host='localhost',port=8089):url:/reset超过了最大重试次数(由NewConnectionError引起(':未能建立新连接:[Errno 8]节点名或提供的servname,或未知'))

如果我自己运行这些测试文件中的任何一个,它们都会通过。我已经调查并删除了错误开始时大致运行的测试文件,但这也没有帮助。我不知道有任何其他方法可以在测试之间重置数据存储,并且终端中的数据存储模拟器输出并不表示存在任何问题,因此我不知道如何解决该问题。

您确定正确关闭了测试中的所有连接吗?听起来有点像套接字耗尽问题。从错误消息中可以看出,您正在为每个请求创建一个新池,而不是为单个主机:端口对重用该池。不管怎样,如果没有adapters.py中的代码或其间任何有趣的转换,都很难提供帮助。My和未经Github上的修改。我来看看游泳池的角度。
ERROR: test_a_thing (my_test.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/my_test.py", line 11, in setUp
  File "/Users/myuser/Projects/MyProject/test/_base_test.py", line 29, in setUp
  File "/Users/myuser/Projects/MyProject/lib/requests/api.py", line 119, in post
  File "/Users/myuser/Projects/MyProject/lib/requests/api.py", line 61, in request
  File "/Users/myuser/Projects/MyProject/lib/requests/sessions.py", line 530, in request
  File "/Users/myuser/Projects/MyProject/lib/requests/sessions.py", line 643, in send
  File "/Users/myuser/Projects/MyProject/lib/requests/adapters.py", line 516, in send
ConnectionError: HTTPConnectionPool(host='localhost', port=8089): Max retries exceeded with url: /reset (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x113715610>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))